Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get client's computer name

Tags:

asp.net

vb.net

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?

like image 993
Mahdi_Nine Avatar asked Dec 12 '25 06:12

Mahdi_Nine


1 Answers

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.

like image 64
Ramon Araujo Avatar answered Dec 13 '25 20:12

Ramon Araujo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!