获得外网和内网IP
来源:互联网 发布:为何注册淘宝要打电话 编辑:程序博客网 时间:2024/04/28 11:24
/// <summary>
/// GetRealIP获得外网和内网IP
/// </summary>
/// <returns></returns>
public static string GetRealIP()
{ // String ClientIP; // //
ClientIP = Request.UserHostAddress; // //
IPHostEntry myHost = Dns.GetHostByAddress(Request.UserHostAddress); // // string UserHostName; // //
UserHostName=myHost.HostName;
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); }
else
{
ip = request.UserHostAddress;
}
}
catch (Exception ex)
{
throw ex;
}
return ip;
}
/// GetRealIP获得外网和内网IP
/// </summary>
/// <returns></returns>
public static string GetRealIP()
{ // String ClientIP; // //
ClientIP = Request.UserHostAddress; // //
IPHostEntry myHost = Dns.GetHostByAddress(Request.UserHostAddress); // // string UserHostName; // //
UserHostName=myHost.HostName;
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); }
else
{
ip = request.UserHostAddress;
}
}
catch (Exception ex)
{
throw ex;
}
return ip;
}
- 获得外网和内网IP
- C/C++ 获得公网ip地址和内网ip
- 内网IP和外网IP
- 获得外网ip
- 获得局域网内IP地址和主机名
- 获取内网和外网IP
- 如何区别内网ip和外网ip?
- 关于内网IP和外网IP
- 关于---内网IP和外网IP
- 如何分辨内网ip和外网ip
- centos 7 查看内网ip和外网ip
- Java-获得内网所有的IP地址
- 公网IP和内网IP
- 公网ip和内网ip
- java 获得外网ip
- java 获得外网ip
- 路由器局域网IP(内网IP)和外网IP的关系
- 外网和内网IP地址范围
- 榕树•梧桐•刺槐——城市的植物意象
- 关于.NET中动态调用Web Service服务的方法心得。
- CCNA全新改版 考试科目变为640-802
- 乡下人的尊严
- 使用WebPart的三种方式
- 获得外网和内网IP
- special mark test
- Linux那些事儿之我是U盘(17)冬天来了,春天还会远吗?(一)
- 一个简单的config配置例子
- dsp,dsw,ncb,opt,clw,plg,aps文件中分别存放的是什么东东,有什么作用?
- 减肥,推荐15种瘦身食品
- 解析.Net框架下的XML编程技术
- 一些vs2005使用经验
- ISTO_nonamed JSP扫描者