IP address of the user who is browsing my website

后端 未结 4 1293
梦毁少年i
梦毁少年i 2021-01-07 07:59

I want to know the IP address of the client machine, i.e. the IP address of the user who is browsing my website. I am trying the following code but it is returning server ad

4条回答
  •  不知归路
    2021-01-07 08:26

    Client IP can be read from request:

    context.Request.ServerVariables["REMOTE_HOST"] 
    

    Here is code for getting more than just client IP address:

    string browserInfo =
                 "RemoteUser=" + context.Request.ServerVariables["REMOTE_USER"] + ";\n"
                + "RemoteHost=" + context.Request.ServerVariables["REMOTE_HOST"] + ";\n"
                + "Type=" + context.Request.Browser.Type + ";\n"
                + "Name=" + context.Request.Browser.Browser + ";\n"
                + "Version=" + context.Request.Browser.Version + ";\n"
                + "MajorVersion=" + context.Request.Browser.MajorVersion + ";\n"
                + "MinorVersion=" + context.Request.Browser.MinorVersion + ";\n"
                + "Platform=" + context.Request.Browser.Platform + ";\n"
                + "SupportsCookies=" + context.Request.Browser.Cookies + ";\n"
                + "SupportsJavaScript=" + context.Request.Browser.EcmaScriptVersion.ToString() + ";\n"
                + "SupportsActiveXControls=" + context.Request.Browser.ActiveXControls + ";\n"
                + "SupportsJavaScriptVersion=" + context.Request.Browser["JavaScriptVersion"] + "\n";
    

提交回复
热议问题