Wednesday, December 10, 2008

How to get the domainname of an ASP.Net application

If the application URL is something like www.myDomain.com/home/homepage.aspx , to get the http://www.mydomain.com/ part from it , we can use the following
(1)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.DnsSafeHost
or
(2)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.Host

No comments: