The issue
I had a situation where I had created a sub site collection and a deployed a asmx websercice to a subfolder in the layouts folder.From codebehind I used HttpContext.Current.Request.Url to get the url of the web service.
If I in the browser entered the address:
- http://server/sites/subsitecol/_layouts/webservice.asmx
- http://server/_layouts/myfolder/webservice.asmx
My workaround
The RawUrl contains the path to the sub site collection. However it is server relative, so I build the absolute url like this (there might be better ways to construct the absolute url):
var uri = new UriBuilder(HttpContext.Current.Request.Url);
uri.Path = HttpContext.Current.Request.RawUrl;
var absoluteurl = uri.Uri.AbsoluteUri;
No comments:
Post a Comment