Question
Host vs DnsSafeHost
I need to get the host out of the Request object. Which property should I use and why?
From MSDN:
Uri.DnsSafeHost Property
A String that contains the unescaped host part of the URI that is suitable for DNS resolution; or the original unescaped host string, if it is already suitable for resolution.
vs
Uri.Host Property
A String that contains the host name. This is usually the DNS host name or IP address of the server.
My testing has been with the ASP.NET Development Server. Both of these always return localhost
. Even when I put in 127.0.0.1, both return localhost
.
Reading on, the DnsSafeHost
property will handle IPv6 addresses, as well as Unicode to ASCII conversion if needed. It can also account for IRI and IDN. Even though I currently don't care about these things, should I just use the DnsSafeHost
property to be safe?