如何获取客户端的IP地址 [英] How to get Client's IP Address
问题描述
我有一个网址。我想知道访问我的URL的用户的IPaddress或Computername。在这里,我将根据我的页面的IP地址或主机名过滤掉。请问有谁可以告诉我如何获取客户的IP地址或Computername?我不想要服务器地址,因为我要在某个远程服务器上托管与此页面相关的Web应用程序。
这应该可以帮到你。
如何获取客户端IP [ ^ ]
你可以使用...
< span class =code-keyword> string ip = Request.UserHostAddress;
string hostname = Request.UserHostName;
更多内容请点击此处..
http://msdn.microsoft.com/en-us/ library / system.web.httprequest.userhostaddress.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostname.aspx [ ^ ]
或者,
http://stackoverflow.com/问题/ 4778886 /如何-可以-I-GET-价值观的计算机的名称和IP地址的 [< a href =http://stackoverflow.com/questions/4778886/how-can-i-get-values-of-computer-name-and-ip-addresstarget =_ blanktitle =New Window> ^ ]
I have a URL . I want to know the IPaddress or Computername of the users who access my URL. Here I am going to filter out based on either IPaddress or Hostname who my page. Can any one please tell me how to obtain Client's Ip address or Computername? I don't want Server address as I am going to host my web Application related to this page at some remote server.
This should help you.
How to get client IP[^]
You can use like..
string ip = Request.UserHostAddress; string hostname = Request.UserHostName;
More from see here..
http://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostaddress.aspx[^]
http://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostname.aspx[^]
Or,
http://stackoverflow.com/questions/4778886/how-can-i-get-values-of-computer-name-and-ip-address[^]
这篇关于如何获取客户端的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!