I have a problem of

value does not fall within the expected range

from below code.

 string webUrl = "/_layouts/15/wfcourrierdep/ArticlesList.aspx";
 string fullpath = SPUtility.GetFullUrl(SPContext.Current.Site,webUrl);           
 SPFile file = web.GetFile(fullpath);

What can the cause be?


1 Answer 1


Please update your "webUrl" variable to be Server Relative. webUrl = "/sites/sitename/_layouts/15/wfcourrierdep/ArticlesList.aspx";

string fullpath = SPUtility.GetFullUrl(SPSite, serverRelativeURL);

Reference http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getfullurl(v=office.15).ASPX

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