ASP.NET C#ブラウザ情報の取得
1921 ワード
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p> :</p>");
Response.Write(" = " + bc.Browser + "<br>");
Response.Write(" = " + bc.Type + "<br>");
Response.Write(" = " + bc.Browser + "<br>");
Response.Write(" = " + bc.Version + "<br>");
Response.Write(" = " + bc.Platform + "<br>");
Response.Write(" = " + bc.Beta + "<br>");
Response.Write(" 16 = " + bc.Win16 + "<br>");
Response.Write(" 32 = " + bc.Win32 + "<br>");
Response.Write(" (frame) = " + bc.Frames + "<br>");
Response.Write(" (table) = " + bc.Tables + "<br>");
Response.Write(" cookie = " + bc.Cookies + "<br>");
Response.Write(" vb script = " + bc.VBScript + "<br>");
Response.Write(" java script = " + bc.JavaScript + "<br>");
Response.Write(" java applets = " + bc.JavaApplets + "<br>");
Response.Write(" activex controls = " + bc.ActiveXControls + "<br>");
}
}
効果のスクリーンショット:
HttpBrowserCapabilitiesには他の属性があり、自分で追加することができます(興味深い属性AOLを発見し、ブラウザがAOL社のブラウザであるかどうかを直接検出します)