SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

Let's say that I have created:

  • A SharePoint site collection at http://mysharepoint/.
  • A subsite of that site collection titled Team site at http://mysharepoint/teamsite/.
  • A list titled My List at http://mysharepoint/teamsite/Lists/mylist/.
  • A list view titled My View at 'http://mysharepoint/teamsite/Lists/mylist/Forms/myview.aspx'

In the Managed Client Object model code, let's say that I managed to reference:

  • The subsite as Web teamsite;
  • The list as List mylist;
  • The list view as View myview;

Is there a way to get the corresponding URLs from those three objects? Thanks.

share|improve this question
i assume you already tried teamsite.Url etc? – int32 Nov 17 '11 at 11:33
Also teamsite will be an SPWeb object, not SPSite. – James Love Nov 17 '11 at 11:42
@AndreasScharf teamsite.Url property does not exist in Managed Client Object model. I haven't been able to find the property/method that would serve my purpose. – Boris Nov 17 '11 at 11:51
@JamesLove Thanks for pointing out the mistake. I've updated my question. – Boris Nov 17 '11 at 11:52
I assume you are refering to the script client object model. Please leave a comment if you needed guidance for the "Microsoft.SharePoint.Client" one ^_^ – SPArchaeologist Nov 17 '11 at 13:34
up vote 6 down vote accepted

You should be able to use the available property to build the url you require. Just be aware that many of the property must be accessed with a *get_method* sintax.

For the SP.Site use the get_url() "property". For the SP.Web use the get_serverRelativeUrl() property and build up the full url.

For the list... don't know if there is an easier way, but you can resort to the get_serverRelativeUrl() property of the root folder (SP.List.get_rootFolder();). Then build the full url from there.

EDIT: As a reference for those that are using the "Microsoft.SharePoint.Client" namespace. On the Site object you can use the .Url property. Since the Web object does not provide an Url property use the ServerRelativeUrl one and build the full url as needed. Also, you must still compensate for the List object not providing any url property. As above, you can resort using the ServerRelativeUrl of the RootFolder of the list.

share|improve this answer
Actually, I was looking for the Microsoft.SharePoint.Client model, but the method names are virtually the same and you resolved my question. Thanks. – Boris Nov 18 '11 at 8:41
ops, sorry. I had read SPSite as SP.Site, so I automatically switched to javascript thinking mode ^_^''. I will update the answer when I get some time on hand. – SPArchaeologist Nov 18 '11 at 9:06
no worries. Thanks for the help. – Boris Nov 18 '11 at 9:08

This is how SP.Web absolute url can be constructed:

var clientContext = new SP.ClientContext.get_current();
var site = clientContext.get_site();
var web = clientContext.get_web();
clientContext.load(site,'ServerRelativeUrl', 'Url');
clientContext.load(web, 'ServerRelativeUrl');
clientContext.executeQueryAsync(Function.createDelegate(this, function (sender, args) {
    var fullWebUrl = site.get_url().replace(site.get_serverRelativeUrl(), 
}), Function.createDelegate(this, function (sender, args) {  }));
share|improve this answer
This helped me, but it only works when site.get_serverRelativeUrl() is longer than "/". A more flexible solution is: if (site.get_serverRelativeUrl() == "/") return site.get_url() + web.get_serverRelativeUrl(); else return site.get_url().replace(site.get_serverRelativeUrl(), web.get_serverRelativeUrl()); – Tor Hovland Apr 20 '12 at 8:27

To get list Properties like URL, ID , Title . Please see below link.

share|improve this answer
While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See answer for general guidelines. – SPDoctor Sep 5 '13 at 9:49

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.