在asp.net中获取IP地址 [英] get the IP add in asp.net

查看:62
本文介绍了在asp.net中获取IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

如果有人从我的网站上下载有关他/她的活动报告到网站,那么我如何获得该计算机的IP?

hello,

If from my website someone is downloading report about his/her activities towards website, then how could i get the ip of that computer?

推荐答案

以下链接可能会帮助您:
在ASP.NET中查找代理后面的IP地址 [ ^ ]
如何在asp.net中获取真实IP地址? [ ^ ]
获取用户IP地址 [ ^ ]

最好.
Following link might help you:
Find IP Address In ASP.NET Behind Proxy[^]
How to get Real IP Address in asp.net?[^]
Retrieve a Users IP Address[^]

All the best.


这里是一个返回Clint IP地址的函数.随时随地调用此函数.
Here is a function which returns Clint IP address. Call this function wherever you need.
public string fnGetClientIP()
{
    string ClientIP= string.Empty;
    string ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    if (!string.IsNullOrEmpty(ip))
    {
        string[] ipRange = ip.Split(',');
        int le = ipRange.Length - 1;
        ClientIP = ipRange[0];
    }
    else
    {
        ClientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    }

    return ClientIP;
}




--Amit




--Amit


这篇关于在asp.net中获取IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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