Here is how you can get the page url after stripping out the QueryParameters from the URL.
UriBuilder builder = new UriBuilder(Request.Url); builder.Query = ""; string urlWithOutQueryParams = builder.ToString();
Other points:
Server.MapPath – is used to convert a virtual path to a physical path. (The virtual path can have the “~” or be relative “..” or “/”)
VirtualPathUtility class has many useful helper methods that can be used to manipulate the path. (http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility_methods.aspx)
Page.ResolveUrl and Control.ResolveUrl can be used within the context of a page to convert a relative path to a URL. (paths that start with “~”, ”..” , ”/”).
Paths starting with a “~” are known as root relative paths or virtual paths. Paths starting with a “..” or a “/” are known as logical paths and are relative to the web-server’s root.
More info:
Making sense of ASP.Net Paths: http://www.west-wind.com/weblog/posts/132081.aspx
No comments:
Post a Comment
Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.