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

推荐订阅源

N
Netflix TechBlog - Medium
C
Cisco Blogs
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
P
Privacy International News Feed
T
Threatpost
小众软件
小众软件
Latest news
Latest news
T
Threat Research - Cisco Blogs
腾讯CDC
L
LINUX DO - 热门话题
Simon Willison's Weblog
Simon Willison's Weblog
NISL@THU
NISL@THU
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
T
Tenable Blog
Cisco Talos Blog
Cisco Talos Blog
博客园 - 【当耐特】
Project Zero
Project Zero
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
G
GRAHAM CLULEY
I
InfoQ
V
V2EX
T
Tailwind CSS Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
Cloudbric
Cloudbric
G
Google Developers Blog
T
Troy Hunt's Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
博客园 - Franky
Martin Fowler
Martin Fowler
罗磊的独立博客
博客园_首页
PCI Perspectives
PCI Perspectives
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
C
Cybersecurity and Infrastructure Security Agency CISA
S
Secure Thoughts
月光博客
月光博客
The Cloudflare Blog
Google Online Security Blog
Google Online Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - wngwz

单点登陆 - wngwz - 博客园 金额转换.小To大 - wngwz - 博客园 简,繁体转换工具. 弹出模态窗体,关闭后。重新绑定页面(这个仅仅是对粗心大意的纪录) - wngwz - 博客园 分页存储过程 关于水晶报表的版本问题! 大年30祝大家, 不知道说还要GMail的油箱! 打印的一些知识! 求助!水晶报表! 解决把水晶报表下载到客户端过程中,出现下载整个页面(.aspx)或者直接载web页中打开word文件的问题! 收获!关于引用计数器! 把文件或图片存在数据库中! 水晶报表倒出! 关于(学习!Excel)的问题。 解决问题总结 水晶报表操作中遇到的问题 javascript 打印报表! javascript 学习
IP地址 - wngwz - 博客园
wngwz · 2006-02-08 · via 博客园 - wngwz

Posted on 2006-02-08 15:13  wngwz  阅读(363)  评论(0)    收藏  举报

备份一下~

        /// <summary>
        
/// 获取IP地址
        
/// </summary>

        public static string IPAddress
        
{
            
get 
            
{
                
string ipAddress = "000.000.000.000";
                
try
                
{
                    
// 有可能是后台调用
                    HttpContext context = HttpContext.Current;                
                    ipAddress 
= GetUserIpAddress(context);
                }

                
catch{}
                
return ipAddress;
            }

        }


        
/// <summary>
        
/// 透过代理获取真实IP
        
/// </summary>
        
/// <param name="context"></param>
        
/// <returns></returns>

        public static string GetUserIpAddress(HttpContext context)
        
{
            
string result = String.Empty;
            
if (context == null
                
return result;

            
// 透过代理取真实IP
            result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            
if (null == result || result == String.Empty)
                result 
= HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            
            
if (null == result || result == String.Empty)
                result 
= HttpContext.Current.Request.UserHostAddress;

            
return result;
        }

刷新页面返回顶部