Home > DeveloperSection > Forums > How to get Domain name
Pawan Shukla

Total Post:34

Points:246
Posted on    October-04-2014 12:07 AM

 ASP.Net .NET  ASP.Net  ASP.NET MVC  C# 
Ratings:


 1 Reply(s)
 580  View(s)
Rate this:
i want to get domain name in asp.net
i'm using this code

string DomainName = HttpContext.Current.Request.Url.Host;

my url is http://localhost:55589/ but it is return only localhost

now i'm want to get http://localhost:55589/ how to possible




Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    October-04-2014 12:11 AM

Try getting the “left part” of the url, like this:

string DomainName = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);

this will return you http://localhost:55589


Don't want to miss updates? Please click the below button!

Follow MindStick