如何知道登录我网站的客户端服务器ip

时间:2013-10-09 05:41:05

标签: c# asp.net networking ip-address

我正在使用波纹管代码来了解客户端IP,但它正在给我的服务器ip,请有人进行必要的更改,如果有的话,

提前致谢,

protected string GetComputer_InternetIP()
{
    // check IP using DynDNS's service
    WebRequest request = WebRequest.Create("http://checkip.dyndns.org");
    WebResponse response = request.GetResponse();
    StreamReader stream = new StreamReader(response.GetResponseStream());

    // IMPORTANT: set Proxy to null, to drastically INCREASE the speed of request
    //request.Proxy = null;

    // read complete response
    string ipAddress = stream.ReadToEnd();

    // replace everything and keep only IP
    return ipAddress.
        Replace("<html><head><title>Current IP Check</title></head><body>Current IP Address: ", string.Empty).
        Replace("</body></html>", string.Empty);
}

0 个答案:

没有答案