Wednesday, March 13, 2013

Get the Client-side/Browser Information

StringBuilder sbBrowserInfo = new StringBuilder();
sbBrowserInfo.Append("
Client Language Preferences");
string Lang = Request.UserLanguages[0];
int count;
String[] userLang = Request.UserLanguages;

for (count = 0; count < userLang.Length; count++)
{
    sbBrowserInfo.Append("
User Language " + Convert.ToInt32(count + 1) + ": " + userLang[count]);
}

sbBrowserInfo.Append("

General Browser Info
");
sbBrowserInfo.Append("RequestType=" + Request.RequestType.ToString() + "
");
sbBrowserInfo.Append("EcmaScriptVersion=" + Request.Browser.EcmaScriptVersion.ToString() + " *Major version greater than or equal to 1 implies JavaScript Support" + "
");
sbBrowserInfo.Append("Browser Type=" + Request.Browser.Type.ToString() + " Client=" + Request.UserAgent + "
");
sbBrowserInfo.Append("UserHostAddress=" + Server.HtmlEncode(Request.UserHostAddress) + "
");
sbBrowserInfo.Append("Table Support=" + Request.Browser.Tables.ToString() + "
");
sbBrowserInfo.Append("UserHostAddress=" + Server.HtmlEncode(Request.UserHostAddress) + "
");
sbBrowserInfo.Append("UserHostName=" + Server.HtmlEncode(Request.UserHostName) + "
");
sbBrowserInfo.Append("HttpMethod=" + Server.HtmlEncode(Request.HttpMethod) + "
");
sbBrowserInfo.Append("Support Java=" + Request.Browser.JavaApplets.ToString() + "
");
sbBrowserInfo.Append("Support HTML Frames=" + Request.Browser.Frames.ToString() + "
");
sbBrowserInfo.Append("Support Cookies=" + Request.Browser.Cookies.ToString() + "
");
sbBrowserInfo.Append(".Net Framework Version Installed=" + Request.Browser.ClrVersion.ToString() + "
");
sbBrowserInfo.Append("Support Channel Definition Format for webcasting=" + Request.Browser.CDF.ToString() + "
");
sbBrowserInfo.Append("Support ActiveXControls=" + Request.Browser.ActiveXControls.ToString() + "
");  //Support
sbBrowserInfo.Append("Support VBScript=" + Request.Browser.VBScript.ToString() + "
");
sbBrowserInfo.Append("Virtual Path of the request=" + Request.FilePath.ToString() + "
");
sbBrowserInfo.Append("Platform=" + Request.Browser.Platform + "
");
sbBrowserInfo.Append("Browser.Win16=" + Request.Browser.Win16 + "
");
sbBrowserInfo.Append("Browser.Win32=" + Request.Browser.Win32 + "
");
sbBrowserInfo.Append("ApplicationPath=" + Request.ApplicationPath + "
");

if (Request.UrlReferrer != null)
{
    sbBrowserInfo.Append("Referring URL Properties
");
    sbBrowserInfo.Append("AbsolutePath=" + Request.UrlReferrer.AbsolutePath + "
");
    sbBrowserInfo.Append("AbsoluteURI=" + Request.UrlReferrer.AbsoluteUri + "
");
    sbBrowserInfo.Append("Authority=" + Request.UrlReferrer.Authority + "
");
    sbBrowserInfo.Append("LocalPath=" + Request.UrlReferrer.LocalPath + "
");
    sbBrowserInfo.Append("Port=" + Request.UrlReferrer.Port + "
");
    sbBrowserInfo.Append("Scheme=" + Request.UrlReferrer.Scheme + "
");
    sbBrowserInfo.Append("UserInfo=" + Request.UrlReferrer.UserInfo + "
");
}

sbBrowserInfo.Append("
More Browser Information
");
foreach (String item in Request.ServerVariables)
    sbBrowserInfo.Append(item + "=" + Request.ServerVariables[item] + "
");

divGeneralInfo.InnerHtml = sbBrowserInfo.ToString();

No comments:

Post a Comment