This article mainly introduces how to obtain the client parameters or operating system information in asp.net, the need for friends can refer to the following
Code as follows:///<summary> ///Get user operating System Information ///</summary> ///<returns></returns& gt; public String Getuseros () { string strsysversion = "Other"; httprequest Request = httpcontext.cur Rent. request; string stragentinfo = request.servervariables["Http_user_agent"]; if ( Stragentinfo.contains ("NT 6.0")) { strsysversion = "Windows Vista"; } else if ( Stragentinfo.contains ("NT 5.2")) { strsysversion = "Windows 2003"; } else if ( Stragentinfo.contains ("NT 5.1")) { strsysversion = "Windows XP"; } else if ( Stragentinfo.contains ("NT 5")) { strsysversion = "Windows"; } else if ( Stragentinfo.contains ("NT 4.9")) { strsysversion = "Windows ME"; } else if ( Stragentinfo.contains ("NT 4")) { strsysversion = "Windows NT4"; } else if (stragentinfo.contains ("NT 98")) { StrsysVersion = "Windows; "} else if (Stragentinfo.contains ("NT)") { strsysversion = "Windows 95"; } Else if (Strsysversion.tolower (). Contains ("Mac")) { strsysversion = "Mac"; } else if (strsysversion.tolower). Contains ("Unix")) { strsysversion = "Unix"; } else if (). Contains ("Linux")) { strsysversion = "Linux"; } else if ("Strsysversion.contains") { strsysversion = "SunOS"; } return strsysversion; } ///<summary> ; ///Get client browser type and version ///</summary> ///<returns></returns> public string Getuserbrowser () { string strbrowser = "Other"; httprequest Request = httpcontext.current.request; String stragentinfo = request.servervariables["Http_user_agent"]; if (Regex.IsMatch (Stragentinfo, "MSIE") ([//d]/ /. [//d]) ", Regexoptions.ignorecase | Regexoptions.compiled)) { Strbrowser = Regex.match (Stragentinfo, "MSIE" [//d]//.[ D]). Result ("ie:$1"); } else if (Regex.IsMatch (Stragentinfo, "Opera" ([//d]//.[ D]) ", Regexoptions.ignorecase | regexoptions.compiled)) { Strbrowser = Regex.match (Stragentinfo, "Opera" ([//d]//.[ D]). Result ("opera:$1"); } else if (Regex.IsMatch stragentinfo, "opera///" ([//d]//.[ D]) ", Regexoptions.ignorecase | regexoptions.compiled)) { Strbrowser = Regex.match (Stragentinfo, "opera///" [//d]//.[ D]). Result ("opera:$1"); } else if (Regex.IsMatch stragentinfo, "firefox///" ([//d]//.[ D]) ", Regexoptions.ignorecase | regexoptions.compiled)) { Strbrowser = Regex.match (Stragentinfo, "firefox///" [//d]//.[ D]). Result ("firefox:$1"); } return strbrowser; } #region getip () ///<summary>& nbsp Get ip ///</summary> ///<returns></returns> public StrinG GetIP () { string uip = ""; if (httpcontext.current.request.servervariables["Http_via"]!= null) { uip = httpcontext.current.request.servervariables["Http_x_forwarded_for"]. ToString (); } else { uip = httpcontext.current.request.servervariables["REMOTE_ADDR"]. ToString (); } return uip; } #endregion