mrblah
mrblah

Reputation: 103507

How to get the domain of the current request?

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?

Upvotes: 10

Views: 11388

Answers (1)

Anton Gogolev
Anton Gogolev

Reputation: 115741

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

Upvotes: 20

Related Questions