What’s the best method in ASP.NET to obtain the current domain?

Same answer as MattMitchell’s but with some modification.
This checks for the default port instead.

Edit: Updated syntax and using Request.Url.Authority as suggested

$"{Request.Url.Scheme}{System.Uri.SchemeDelimiter}{Request.Url.Authority}"

Leave a Comment