Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the domain of the current request?

Tags:

c#

asp.net

In asp.net, I want to get just the domain information?

i.e localhost or example.com

possible?

can this value ever be null or its 100% gauranteed to return a value?

like image 520
mrblah Avatar asked Oct 02 '09 14:10

mrblah


1 Answers

HttpContext.Current.Request.Url.Authority. Or replace .Authority with something more appropriate.

like image 115
Anton Gogolev Avatar answered Oct 28 '22 16:10

Anton Gogolev