惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 周奇

程序员大杯具:蜗居中的小贝是搞C++的 获取Repeater中TextBox中的值 - 周奇 - 博客园 Repeater 实现批量,删除.全选.分页 - 周奇 - 博客园 Repeater 实现删除 - 周奇 - 博客园 Google和百度收录网站页面的比较 Js做的动态Flash - 周奇 - 博客园 设为首页代码大全 - 周奇 - 博客园 asp.net不刷新显示隐藏的办法(心得) - 周奇 - 博客园 统计网页访问量的JAVA Script代码 - 周奇 - 博客园 解决IE6、IE7、Firefox兼容最简单的CSS Hack 过滤html(转) - 周奇 - 博客园 联合查询 sql语句的联合查询(join 用法) 功能超多的JS验证表单大全 Repeater 删除 记录 功能 实现 链接数据库超时 向google,baidu,yahoo,msn,sogou等搜索引擎提交网站 娶个女程序员的好处 最简单的mp3播放器,只有播放和暂停
APS.NET获取用户端真实IP - 周奇 - 博客园
周奇 · 2009-11-04 · via 博客园 - 周奇

asp.net的request自带一个获取用户端ip的属性 request.userhostaddress,但通过userhostaddress获取的ip地址并不能保证真实、准确,并且上客户端使用了代理怎么办?

                if (request.servervariables["remote_addr"] != null)//发出请求的远程主机的ip地址
        {
                    this.ipaddress = request.servervariables["remote_addr"].tostring();
                }
                else if (request.servervariables["http_via"] != null)//判断是否设置代理,若使用了代理
        {
                    if (request.servervariables["http_x_forwarded_for"] != null)//获取代理服务器的ip
                    {
                        this.ipaddress = request.servervariables["http_x_forwarded_for"].tostring();
                    }
                    else
                    {
                        this.ipaddress = request.userhostaddress;
                    }
                }
                else
                {
                    this.ipaddress = request.userhostaddress;
                }
使用上述代码,可以保证准确的获取到客户端ip地址。