I have an application page: ApprovedReassessments with this url :


and I have a library : DropDownLibrary with this url:


when I try to call this library in the application page :

     string DROPDOWNLIBRARY_FIELDS = "<FieldRef Name='{0}' /><FieldRef Name='{1}' /><FieldRef Name='{2}' /><FieldRef Name='{3}' /><FieldRef Name='{4}' /><FieldRef Name='{5}' /><FieldRef Name='{6}' /><FieldRef Name='{7}' /><FieldRef Name='{8}' /><FieldRef Name='{9}' /><FieldRef Name='{10}' />";
    SPQuery objQuery = new SPQuery();
    objQuery.ViewFields = string.Format(DROPDOWNLIBRARY_FIELDS, SharePoint_Assessment_Fields.AGENTID_FIELD, SharePoint_Assessment_Fields.ID_FIELD,
                         SharePoint_Assessment_Fields.CREATED_FIELD, SharePoint_Assessment_Fields.SALESFORCECASENUMBER_FIELD, SharePoint_Assessment_Fields.COUNTRY_CODE_FIELD,
                         SharePoint_Assessment_Fields.FILELEAFREF_FIELD, SharePoint_Assessment_Fields.FILEREF_FIELD, SharePoint_Assessment_Fields.ASSESST_STATUS_FIELD,
                         SharePoint_Assessment_Fields.REVIEWTYPE_FIELD, SharePoint_Assessment_Fields.PAXORCARGO_FIELD, SharePoint_Assessment_Fields.SUBMITTEDDATE_FIELD
  objQuery.Query = "<Where><And><Eq><FieldRef Name=\"ID\"/><Value Type=\"Integer\">" + salesforceCaseNumber + "</Value></Eq><Eq><FieldRef Name=\"ID\"/><Value Type=\"Integer\">" + agentId + "</Value></Eq></And></Where>";                   
 SPList dropDownList = this.currentWeb.GetList(SPUrlUtility.CombineUrl(this.currentWeb.ServerRelativeUrl, DocumentLibrary.DROPDOWN)); ...

the last line return this error :

 cannot complete this action please try again 

PS : I have a webpart who call the same library, and it works but not in application page any idea please ?

3 Answers 3


Lists takes the title or the list id. What you're passing in looks like the partial URL.

  • I m trying the second code SPList dropDownList = this.currentWeb.GetList(SPUrlUtility.CombineUrl(this.currentWeb.ServerRelativeUrl, DocumentLibrary.DROPDOWN)); because it works in webpart and not in application page error : cannot complete this action please try again
    – BKChedlia
    Commented Aug 4, 2016 at 12:57

Check http://<url>/FormServerTemplates

Go to the above URL > Settings > Library Settings > Permission to this Library and provide permission to your user.

Also, check if it's just for one library or its happening for all the library. looks a permission issue.

  • I will check it but I m not sure because in a webpart (in home page) I can access to library, with same code
    – BKChedlia
    Commented Aug 4, 2016 at 13:15
  • Webpart must be using elevated priviliges thats why Commented Aug 4, 2016 at 13:15
  • no elevated priviliges on the webpart, and I have full control on the doc library, but still not working
    – BKChedlia
    Commented Aug 4, 2016 at 13:46
  • In Form Server Templates also you have permission too? Commented Aug 4, 2016 at 14:18

I tried this solution and it works :

using (SPSite curSite = new SPSite(SPContext.Current.Web.Url))
                curSite.AllowUnsafeUpdates = true;
                using (SPWeb curWeb = curSite.OpenWeb())
                    curWeb.AllowUnsafeUpdates = true;
                    SPList list2 = curWeb.GetList(SPUrlUtility.CombineUrl(curWeb .ServerRelativeUrl.TrimEnd('/'), "/Lists/ListName"));
                    curWeb.AllowUnsafeUpdates = false;
                curSite.AllowUnsafeUpdates = false;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.