asp.net获取访问者ip地址的函数
/// <summary>
/// 获取IP地址
/// </summary>
public static string IPAddress
{
get
{
string userIP;
HttpRequest Request = HttpContext.Current.Request;
// 如果使用代理,获取真实IP
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
userIP = Request.ServerVariables["REMOTE_ADDR"];
else
userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (userIP == null || userIP == "")
userIP = Request.UserHostAddress;
return userIP;
}
}
版权声明:
作者:亦灵一梦
链接:https://blog.haokaikai.cn/2018/program/aspnet/659.html
来源:开心博客
文章版权归作者所有,未经允许请勿转载。
THE END
1
二维码
海报
asp.net获取访问者ip地址的函数
/// <summary>
/// 获取IP地址
/// </summary>
public static string IPAddress
{
get
{
string userIP;
HttpRequest Request = HttpContext.Curr……