C# 如何知道谁登录了我的网站

C# 如何知道谁登录了我的网站,c#,asp.net,networking,ip-address,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.GetRespo

我使用下面的代码来了解客户端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);
}
受保护的字符串GetComputer\u InternetIP()
{
//使用DynDNS的服务检查IP
WebRequest=WebRequest.Create(“http://checkip.dyndns.org");
WebResponse=request.GetResponse();
StreamReader stream=新的StreamReader(response.GetResponseStream());
//重要提示:将Proxy设置为null,以大幅提高请求速度
//Proxy=null;
//阅读完整的回答
字符串ipAddress=stream.ReadToEnd();
//替换所有内容并仅保留IP
返回IP地址。
替换(“当前IP检查当前IP地址:”,string.Empty)。
替换(“,string.Empty);
}

是的,因为是服务器向DynDns发出请求,所以检测到的是服务器的IP。检查并尝试这样做,比如为什么webrequest要从其他地方获取它?试试:或者试试这个……stackoverflow.com/questions/735350/,是的,我在这里得到了答案,谢谢,