如何在asp.net中获取真实的IP地址? [英] How to get real Ip address in asp.net?
本文介绍了如何在asp.net中获取真实的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上,我在asp.net中创建了一个注册表单....我想获取真实的IP地址,谁都以我的注册表单进行注册???
Actually i created one registration form in asp.net....i wanna get real ip address, who all register in my register form????
推荐答案
这可能是最好的解决方案,获取IP地址
This might be the best solution , to get the IP address
public string GetUserIP()
{
string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ipList))
{
return ipList.Split(',')[0];
}
return Request.ServerVariables["REMOTE_ADDR"];
}
这篇关于如何在asp.net中获取真实的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文