How To: Construct absolute url for any item using the SPSite object

In the case when we need to get the absolute url for any item, we can make use of the instance method SPSite.MakeFullUrl.

Example use,-

using(SPSite site = new SPSite(mysiteurl))
{     using(SPWeb web = site.OpenWeb())
    {
      //.. Other lines of code
      string absoluteURL = site.MakeFullUrl(serverRelativeURL);
    }
}

 

Published 09 August 08 09:37 by Subhajit.Chatterjee
Filed under:

Comments

No Comments
New Comments to this post are disabled

Search

This Blog

Syndication

Page view tracker