您的位置:首页 > 编程语言 > ASP

asp.net 取得远程的IP地址和浏览器类型

2007-05-05 23:51 295 查看
/############################################
版权声明:
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必明文标注文章原始出处及本声明
http://www.opent.cn 作者:浪淘沙
############################################/


#region 取得远程的IP地址和浏览器类型
/// <summary>
/// 取得远程的IP地址和浏览器类型
/// </summary>
/// <returns></returns>
public static string GetIp()
{
string str = "";
//穿过代理服务器取远程用户真实IP地址:
if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
str = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
else
str = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();

HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
bc = System.Web.HttpContext.Current.Request.Browser;
str += " 你的操作系统:" + bc.Platform + " 浏览器:" + bc.Type;
return str;
}
#endregion
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: