现在的位置: 首页 > 综合 > 正文

C#如何获取客户端/服务端IP地址

2013年10月29日 ⁄ 综合 ⁄ 共 474字 ⁄ 字号 评论关闭

 

客户端ip:
Request.ServerVariables.Get("Remote_Addr").ToString();
客户端主机名:
Request.ServerVariables.Get("Remote_Host").ToString();
客户端浏览器IE:
Request.Browser.Browser;
客户端浏览器 版本号:
Request.Browser.MajorVersion;//
客户端操作系统:
Request.Browser.Platform;

服务器ip:
Request.ServerVariables.Get("Local_Addr").ToString();
服务器名:
Request.ServerVariables.Get("Server_Name").ToString();

如果你想进一步了解ServerVariables,可以用
foreach(String o in Request.ServerVariables){
Response.Write(o+"="+Request.ServerVariables[o]+"<br>");
}

抱歉!评论已关闭.