I need to fetch the domain name and path from the request to provide the following return values:
domain1.com/default.aspx returns domain1.com/default.aspx
domain1.com/ returns domain1.com/
domain1.com returns domain1.com
At the moment every URL fetch function I try seems to return domain.com/default.aspx no matter what the address bar in my browser says. Any solution to this?
I’ve tried lots of different built-in functions to retrieve parts of the request but none seem to provide the desired results.
There is a solution to your problem.
HttpContext.Current.Request.Urlwill return aUriobject that contains all the parts of the URL broken down for you. From that, you should be able to get what you’re looking for. Specifically, the property you want is Uri.Authority.EDIT: Try something like this: