Request ServerVariables Common Task

ASP.Net Get address for website

Get the address for the website.
You want to retrieve the full address of the website that the request came to. Do not use "SERVER_NAME", use "HTTP_HOST". The address returned is the name that the request came in to.

Example, for http://www.asd.com:123, SERVER_NAME would return www.asd.com whereas HTTP_HOST would return www.asd.com:123
string addressToWebSite = Request.ServerVariables["HTTP_HOST"]);
Dim addressToWebSite As String = Request.ServerVariables("HTTP_HOST")
Related ServerVariables HTTP_HOST SERVER_NAME
     << Back