none
Where can I find the file containing SPweb to make absolute url's RRS feed

  • Question

  • I'm trying to implement code making all url's absolute.  However, I'm unable to locate the SPweb object to change it.  Any help would be greatly appreciated.  Thank you.

    Daniel

    Wednesday, July 6, 2011 1:40 PM

Answers

  • Thanks for the response Galvatron, I had a few more questions.  Will this make all the site relative urls absolute?  Is it going to be done in powershell or is there a place I can see and edit the code like a master file?  On the code you posted it would then be SPSite.MakeFullUrl(string siteRelativeUrl) that is exactly what needs to be put in?

    Daniel.MS, ok, now i see your target more clean. If you want to create absolute url from any site-relative url, then you should use following algorithm:

    <absolute url> = SPSite.MakeFullUrl( SPWeb.ServerRelativeUrl + <something site(web) relative>)

     

    This objects can be used both in powershell and .net applications running on the server, where sharepoint object model is available.


    Ivan Gorbadey. Sharepoint 2010 MCPD & MCITP.
    • Marked as answer by Daniel.MS Wednesday, July 6, 2011 5:42 PM
    Wednesday, July 6, 2011 5:28 PM

All replies

  • Its not obvious what for to change SPWeb object.

    You just need SPWeb, SPList, SPListItem or any other object to get its url...absolute or relative..

    You can make server relative urls to be absolute by this code:

    SPSite.MakeFullUrl(string siteRelativeUrl)

     

    Also depending on context you may have or have not access to SPContext.Current.Web object, SPContext.Current.Site object etc.

     

    Usually its enough to use serverrelative urls, not absolute. For example SPWeb.ServerRelativeURL, SPFile.ServerRelativeUrl etc


     

     


    Ivan Gorbadey. Sharepoint 2010 MCPD & MCITP.




    Wednesday, July 6, 2011 2:35 PM
  • Thanks for the response Galvatron, I had a few more questions.  Will this make all the site relative urls absolute?  Is it going to be done in powershell or is there a place I can see and edit the code like a master file?  On the code you posted it would then be SPSite.MakeFullUrl(string siteRelativeUrl) that is exactly what needs to be put in?

    Wednesday, July 6, 2011 2:46 PM
  • Thanks for the response Galvatron, I had a few more questions.  Will this make all the site relative urls absolute?  Is it going to be done in powershell or is there a place I can see and edit the code like a master file?  On the code you posted it would then be SPSite.MakeFullUrl(string siteRelativeUrl) that is exactly what needs to be put in?

    Daniel.MS, ok, now i see your target more clean. If you want to create absolute url from any site-relative url, then you should use following algorithm:

    <absolute url> = SPSite.MakeFullUrl( SPWeb.ServerRelativeUrl + <something site(web) relative>)

     

    This objects can be used both in powershell and .net applications running on the server, where sharepoint object model is available.


    Ivan Gorbadey. Sharepoint 2010 MCPD & MCITP.
    • Marked as answer by Daniel.MS Wednesday, July 6, 2011 5:42 PM
    Wednesday, July 6, 2011 5:28 PM
  • Galvatron83,

    Thank you for all the help!  Thats excatly what I need to know.

    Daniel

    Wednesday, July 6, 2011 5:43 PM