如何获取用户机器的IP地址。 [英] How to get Ip address of users machine.

查看:83
本文介绍了如何获取用户机器的IP地址。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,我需要在获取IP时跟踪用户机器的ip以获取安全性。当该机器与代理服务器相关时,我无法获得本地机器ip。我想获得本地机器的IP,即使它有代理服务器。

如何获得该IP可以帮助我吗?





比你提前

I have one web application in that i need to track the ip of user's machine for security rision at the time of getting ip i'm not able to get local machine ip when that machin is related with proxy server. I want to get ip of local machine even it is having proxy server.
How to get that ip can any one assist me?


Than you in advance

推荐答案

你做过什么只是Google it and try Something如果你仍然面对此处发布的任何特定问题请尝试使用 HttpRequest.UserHostAddress Property ... 。
Have You tried anything just Google it and try Something If still you are facing any specific issue post here Try Using HttpRequest.UserHostAddress Property ....


在几个小时之前看到我发布的这个答案:获取客户端IP地址 [ ^ ]
See this answer posted by me just before few hours : Get Client IP Address[^]


你可以尝试下面的代码

can you tried below code
protected void GetUser_IP()
{
    string VisitorsIPAddr = string.Empty;
    if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
    {
        VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
    }
    else if (HttpContext.Current.Request.UserHostAddress.Length != 0)
    {
        VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress;
    }
    uip.Text = "Your IP is" + VisitorsIPAddr;
}


这篇关于如何获取用户机器的IP地址。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆