Copy Code code as follows:
<summary>
Get user Operating System Information
</summary>
<returns></returns>
public string Getuseros ()
{
String strsysversion = "other";
HttpRequest Request = HttpContext.Current.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 2000";
}
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 98";
}
else if (Stragentinfo.contains ("NT 95"))
{
Strsysversion = "Windows 95";
}
else if (Strsysversion.tolower (). Contains ("Mac"))
{
Strsysversion = "Mac";
}
else if (Strsysversion.tolower (). Contains ("Unix"))
{
Strsysversion = "UNIX";
}
else if (Strsysversion.tolower (). Contains ("Linux"))
{
Strsysversion = "Linux";
}
else if (Strsysversion.contains ("SunOS"))
{
Strsysversion = "SunOS";
}
return strsysversion;
}
<summary>
Get the 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>
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