本文介绍了获取远程IP地址或计算机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有发表在服务器上我的GUI文件...此服务器是IIS运行的位置。

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

现在访问我的图形用户界面从远程计算机。我怎样才能得到这个机器的IP地址或用户名。

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

我得到使用这个code机器的服务器名称:

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

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

请帮助谢谢...

也许我还不够清楚:

让我再解释一下。

有2台A和B。一个是我有我的公布文件的图形用户界面,并在IIS ...上面code给我的机器A的名字

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

现在我打电话从机器B的GUI,我想机器B的名字

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

推荐答案

要从Asp.Net得到一个远程用户的IP,可以使用 Request.ServerVariables [REMOTE_ADDR] Request.UserHostAddress

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

请求对象应该是可在任何地方在你的ASPX页面。

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

我不认为这是有可能通过ServerVariables可靠地获得主机名。

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

这篇关于获取远程IP地址或计算机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 12:28
查看更多