get remote Ip address or machine name

被刻印的时光 ゝ 提交于 2019-12-11 07:01:23

问题


I have my GUI files published on a server... this server is where the IIS is running..

Now i access my GUI from a remote machine. how can i get this machines IP address or username.

I get the server name of the machine using this code:

string svrName = System.Net.Dns.GetHostName();

please help thanks...

maybe i was not clear enough:

Let me explain again..

there are 2 machines A and B.. A is where i have my published files for the GUI and also the IIS... the above code gives me the name of machine A

now i call the GUI from machine B. and i want the name of machine B


回答1:


To get a remote user's IP from Asp.Net, you can use Request.ServerVariables["REMOTE_ADDR"] or Request.UserHostAddress.

The Request object should be available anywhere in your ASPX page.

I don't think it's possible to reliably get the hostname through ServerVariables.




回答2:


Assuming I understand what you're asking, System.Web.HttpContext.Current.Request will give your server-side code lots of information about the client making the request.



来源:https://stackoverflow.com/questions/4260975/get-remote-ip-address-or-machine-name

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