SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having the following exception when trying to get a list that I know it exists.

yes, I know the using should not be used in this case but thats not my code :), but I dont think thats the problem

 using (SPWeb CurrentSite = SPContext.Current.Site.RootWeb)
                string listUrl = string.Format("{0}/Lists/RequestAccess", CurrentSite.Url);
                SPList list = CurrentSite.GetList(listUrl);

enter image description here

share|improve this question
up vote 3 down vote accepted

As per msdn SPWeb.GetList accepts server relative url, but you pass absolute url, may be this is the issue.

share|improve this answer
Use the CurrentSite.ServerRelativeUrl. Also ensure to check for the trailling backslash so you dont get two of them. – Roman Apr 14 '12 at 2:43

If you are facing issues with SpWeb.Getlist() then instead of that you can SpWeb.Lists["ListName"] which takes list title as parameter. no need to provide the URL.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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