asp.net 获取客户端ip地址
以下是asp.net获得客户端ip地址的方法!
1. HttpContext.Current.Request.UserHostAddress;
使用方法:string strip=HttpContext.Current.Request.UserHostAddress;
2.HttpContext.Current.Request.ServerVariables[“REMOTE_ADDR”];
使用方法:同上
3.string?strHostName?=?System.Net.Dns.GetHostName();
string?clientIPAddress?=?System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
4.HttpContext.Current.Request.ServerVariables[“HTTP_X_FORWARDED_FOR”];
5.function?GetLocalIPAddress() { var obj = null; var rslt = “”; try { obj = new ActiveXObject(“rcbdyctl.Setting”); rslt = obj.GetIPAddress; obj = null; } catch(e) { // } return rslt; }
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 WEIXING.ME!
评论