I saw this question in another post but the solution did not work correctly. I use:
System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST")).HostName
This worked correctly on localhost but on server it has problems and returns an empty string. Any idea?
Take into account that HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST") will return the name of the host making the request, not the address.
Try doing System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST")).HostName instead.
You can find a list of the Server Variables at Microsoft's MSDN website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With