Hi, I'm trying to retrieve client host name information to record into a database, but request.userhostname only returns an IP address... I'm aware that you should be able to enable IIS to automatically complete a reverse DNS Lookup which gives you the host name... but can't figure out how to do it. Could anyone give me a few pointers please?
This is what I use but it has nothing to do with IIS settings. Be aware it doesn't always work because a reverse DNS lookup based on IP address is sometimes not possible. Code: string clientHostName = "Undetermined"; IPHostEntry iphostEntry; try { iphostEntry = Dns.GetHostEntry(Request.UserHostAddress); clientHostName = iphostEntry != null ? iphostEntry.HostName : clientHostName; } catch (SocketException) { iphostEntry = Dns.Resolve(Request.UserHostAddress); clientHostName = iphostEntry != null ? iphostEntry.HostName : clientHostName; }