How get client (user) machine name (computer name) with jQuery or JavaScript or server-side codes. (scrutiny of possible ways)

社会主义新天地 提交于 2019-12-11 02:09:31

问题


I was working on Retrieving IP address and client machine name for few days on the internet (not on the local network)
so I found some ways for getting IP-address , but I couldn't find a way for getting client machine name or gathering some info about my web site users ?
I know there are many duplicate threads about this issue out there , but many of them are old or do n't work.
the below server side codes return SERVER NAME Not client computer name !

string UserHost_ComputerName4 = Dns.GetHostName();//Server Name
string UserHost_ComputerName5 = Environment.MachineName;//Server Name  

and the below line have error on user-side , but it works on server-side page running :

 string UserHost_ComputerName3 = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName.ToString();//Has Error

Would you lead me to a possible and workable ways (JavaScript or jQuery or server side) for getting client (users who are visiting my web site) machine name?


回答1:


As far as I remember, in order to get:

  • Request.ServerVariables["REMOTE_ADDR"]
  • Request.ServerVariables["REMOTE_HOST"]
  • Request.ServerVariables["REMOTE_USER"]

you have to enable Reverse DNS Lookup for you IIS.

p.s. atm I'm not able to test it myself, so I'm not quite sure if this will solve ur problem




回答2:


Try this:

string PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName;

But if you want Name of Host PC

string HostPCName = Dns.GetHostName();



回答3:


Not entirely sure on all the ways you can do this, but it would be possible through ActiveX, which could be a problem as that only works in some browsers. I don't believe there is a way you can do it with pure javascript, and it's not possible serverside as the server does not get access to such details of it's connected clients.



来源:https://stackoverflow.com/questions/6691565/how-get-client-user-machine-name-computer-name-with-jquery-or-javascript-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!