I am writing code in my master page that examines the page's URL as shown in the browser
I have a web application at URL:
and many site collections within it like this:
http://teams.sharepoint.org/sitecollections/site1 http://teams.sharepoint.org/sitecollections/site2 http://teams.sharepoint.org/sitecollections/site3
The code snippet I am using to examine the URL is:
Uri uri = Context.Request.Url; StringBuilder sb = new StringBuilder(); sb.Append(" uri.AbsolutePath = " + uri.AbsolutePath + "<br />"); sb.Append("uri.AbsoluteUri = " + uri.AbsoluteUri + "<br />"); Response.Write(sb.ToString());
When I navigate to any of the above site collections the returned path is as expected.
Full URL to Page: http://teams.sharepoint.org/sitecollections/site1/Pages/default.aspx Output of code snippet: uri.AbsolutePath = /sitecollections/site1/Pages/default.aspx uri.AbsoluteUri = http://teams.sharepoint.org/sitecollections/site1/Pages/default.aspx
Now notice what is returned when I navigate to the site settings page for any of the site collections.
The URL to the site settings is:
But now the code snippet returns only the /_layouts/settings.aspx portion and does not return the '/sitecollections/site1/' portion of the URL.
uri.AbsolutePath = /_layouts/settings.aspx uri.AbsoluteUri = http://teams.sharepoint.org/_layouts/settings.aspx
Why is that omitted? The omitted portion is the part that I need to examine and act on but it is not returned.
Thanks for reading