Suppose you are running your ASP.NET application on a domain like http://www.mydomain.com, and you want to access this domain (www.mydomain.com) in your code. The below method can be used to get the host name:
string host= HttpContext.Current.Request.Url.Host;
One problem with this is that it will not get port number. For detailed explanation and other possible solutions, refer this link for details:
Here is another solution which handles port number too.