Working with URLs in SharePoint, using SPUrlUtility.CombineUrl


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. string root = "/";
  2. string path = "/sub";
  3. string doc = "/sub/default.aspx";
  4.  
  5. Console.WriteLine(String.Format("SPUrlUtility.CombineUrl(root, path): {0}", SPUrlUtility.CombineUrl(root, path)));
  6. // "/sub"
  7. Console.WriteLine(String.Format("SPUrlUtility.CombineUrl(root, doc): {0}", SPUrlUtility.CombineUrl(root, doc)));
  8. // "/sub/default.aspx"
  9. Console.WriteLine(String.Format("SPUrlUtility.CombineUrl(path, doc): {0}", SPUrlUtility.CombineUrl(path, doc)));
  10. // "/sub/default.aspx"
  11. Console.WriteLine(String.Format("SPUrlUtility.CombineUrl(path, doc): {0}", SPUrlUtility.CombineUrl("/", "/_layouts/mypage.aspx")));
  12. // "/_layouts/mypage.aspx"

URL: http://blog.hompus.nl/2009/03/09/working_with_urls_in_sharepoint/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.