Posted By

scholli on 11/03/10


Tagged

url sharepoint


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Tyster
jlaws0n


Working with URLs in SharePoint, using SPUrlUtility.CombineUrl


 / Published in: C#
 

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

  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"

Report this snippet  

You need to login to post a comment.