C# 获取客户端信息 /asp.net/WebService/WebForm

Request.Browser.MajorVersion.ToString();//获取客户端浏览器的(主)版本号
Request.Browser.Version.ToString();   //获取客户端浏览器的完整版本号
Request.Browser.Platform.ToString();  //获取客户端使用平台的名字
Request.UserHostAddress.ToString();   //获取远程客户端主机IP
HttpRequest.Url.ToString();           //获取有关当前请求的URL的信息。  
HttpRequest.UrlReferrer.ToString();   //获取有关客户端上次请求的URL的信息,该请求链接到当前的    URL。  
HttpRequest.UserAgent.ToString();       //获取客户端浏览器的原始用户代理信息。  
HttpRequest.UserHostAddress.ToString(); //获取远程客户端的IP主机地址。  
HttpRequest.UserHostName.ToString();    //获取远程客户端的DNS名称。  
HttpRequest.UserLanguages.ToString();   //获取客户端语言首选项的排序字符串数组。
 
 
 
System.Web.HttpBrowserCapabilities browser = Request.Browser;
    string s = "Browser Capabilities\n"
       + "Type = "                     + browser.Type + "\n"
       + "Name = "                     + browser.Browser + "\n"
       + "Version = "                  + browser.Version + "\n"
       + "Major Version = "            + browser.MajorVersion + "\n"
       + "Minor Version = "            + browser.MinorVersion + "\n"
       + "Platform = "                 + browser.Platform + "\n"
       + "Is Beta = "                  + browser.Beta + "\n"
       + "Is Crawler = "               + browser.Crawler + "\n"
       + "Is AOL = "                   + browser.AOL + "\n"
       + "Is Win16 = "                 + browser.Win16 + "\n"
       + "Is Win32 = "                 + browser.Win32 + "\n"
       + "Supports Frames = "          + browser.Frames + "\n"
       + "Supports Tables = "          + browser.Tables + "\n"
       + "Supports Cookies = "         + browser.Cookies + "\n"
       + "Supports VBScript = "        + browser.VBScript + "\n"
       + "Supports JavaScript = "      + browser.JavaScript + "\n"
       + "Supports Java Applets = "    + browser.JavaApplets + "\n"
       + "Supports ActiveX Controls = " + browser.ActiveXControls + "\n";
    TextBox1.Text = s;
 
//////////////////////////////////////////////////////////////////////////////////////
在.NET中,WebService和WebForm页面
 
Web Service使用(通过HttpContext对象调用Request对象):
HttpContext.Current.Request.UserHostAddress
HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0]
Web Form使用(可直接使用Request对象):
Request.ServerVariables.GetValues("REMOTE_ADDR")[0]
HttpContext.Current.Request.UserHostAddress

posted @ 2013-08-18 18:37  kingboy  阅读(4330)  评论(1编辑  收藏  举报