How to ensure to always get domain name when using Url.Authority or Url.Host with Asp.Net
Posted on 2017-01-04
Microsoft's documentation states that it may return either the Host name or the IP address but it doesn't say how the framework determines which one to return. I'm having a problem in a production environment where Url.Authority returns the host name sometimes and at other times returns the IP address.
I need to ensure that it returns the host name every time. I've created a workaround for the moment but its not ideal, I need to figure out how to fix this.
I'm using the .NET Framework version 4.6.1 in all environments.