如何在ASP.NET网站中从Web服务器查找客户端IP地址

问题描述:

嗨''

我在ASP.NET开发了一个网站

根据IP系统地址

网站正在运行。

当我从本地主机运行网站时工作正常。

但是当我我正在从网络服务器端浏览网站。

我没有得到系统的正确IP地址

它正在浏览。

i我正在使用以下代码来获取系统的IP地址

Hi''
I have developed a website in ASP.NET
In which I am performing some Task
According to the IP address of the system
Where the site is Running.
Its working Fine When I am Running the Site from Local Host.
But when I am browsing the Site from web server end.
I am not getting the Correct IP address of the System where
it is getting browsed.
i am using folowing code to fetch the Ip Address of the System

strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostEntry(strHostName).AddressList(0).ToString()



有没有其他方法可以找到系统的IP地址,

请协助


is there any other method to find the IP address of System,
please Assist

试试这个





Try this


StrIPAdd = Request.ServerVariables("REMOTE_ADDR")