获取IP地址 [英] get IP address

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

问题描述

我想获取我的网站用户的IP地址并在标签上显示.
怎么可能呢?那里有个想法并想帮助我的人...:)

I want to get IP address of my website viwers and show it on label.
How it is possible? Anyone there who got an idea and like to help me... :)

推荐答案



HttpRequest.UserHostAddress

您可以使用页面的Request属性访问页面的HttpRequest.

问候
Espen Harlinn
Hi,

HttpRequest.UserHostAddress

You can access the HttpRequest of your page using the Request property of your page.

Regards
Espen Harlinn


label1.Text = Request.UserHostAddress.ToString();


尝试一下服务器变量为
Try with the server variables as
HttpContext.Current.Request.UserHostAddress;
or
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
To get the IP address of the machine and not the proxy use the following code
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"
];


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

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