打印本文 打印本文  关闭窗口 关闭窗口
ASP.Net写的浏览器间谍
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005/9/10 12:38:11
下面是我写的一个关于HttpBrowserCapabilities组件的应用例子。

程序执行的例子在 http://aspx1.brinkster.com/feidao/code/BrowserSpy.aspx

下面是源程序:

<html>
<head>
  <script runat="server" language="c#">
    public void Page_Load(Object Source, EventArgs E)
    {
      HttpBrowserCapabilities bc= Request.Browser;

      Welcome.Text = "您好,您正在使用 " + bc.Browser + " v." + bc.Version + ",你的运行平台是 " + bc.Platform ;


      ActiveXControls.Text = bc.ActiveXControls.ToString();
      AOL.Text = bc.AOL.ToString();
      BackgroundSounds.Text = bc.BackgroundSounds.ToString();
      Beta.Text = bc.Beta.ToString();
      Browser.Text = bc.Browser.ToString();
      CDF.Text = bc.CDF.ToString();
      Cookies.Text = bc.Cookies.ToString();
      Crawler.Text = bc.Crawler.ToString();
      Frames.Text = bc.Frames.ToString();
      JavaApplets.Text = bc.JavaApplets.ToString();
      JavaScript.Text = bc.JavaScript.ToString();
      MajorVersion.Text = bc.MajorVersion.ToString();
      MinorVersion.Text = bc.MinorVersion.ToString();
      Platform.Text = bc.Platform.ToString();
      Tables.Text = bc.Tables.ToString();
      Type.Text = bc.Type.ToString();
      VBScript.Text = bc.VBScript.ToString();
      Version.Text = bc.Version.ToString();
      Win16.Text = bc.Win16.ToString();
      Win32.Text = bc.Win32.ToString();
    }
  </script>
<asp:Label id="css1" runat="server" />
</head>
<body>
<form runat="server" method="post">
您的浏览器信息已经完全在我们的掌握中了^&^:<br>
<p><asp:Label runat="server" id="Welcome" Font-Bold="True" /></p>
<table border="1" width="400" bordercolor="black" cellpadding="4" cellspacing="0">
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>浏览器属性</b></td>
  <td width="50%"><b>测试结果</b></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>ActiveXControls:</b></td>
  <td width="50%"><asp:Label runat="server" id="ActiveXControls" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>AOL:</b></td>
  <td width="50%"><asp:Label runat="server" id="AOL" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>BackgroundSounds:</b></td>
  <td width="50%"><asp:Label runat="server" id="BackgroundSounds" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>Beta:</b></td>
  <td width="50%"><asp:Label runat="server" id="Beta" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>Browser:</b></td>
  <td width="50%"><asp:Label runat="server" id="Browser" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>CDF:</b></td>
  <td width="50%"><asp:Label runat="server" id="CDF" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>Cookies:</b></td>
  <td width="50%"><asp:Label runat="server" id="Cookies" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>Crawler:</b></td>
  <td width="50%"><asp:Label runat="server" id="Crawler" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>Frames:</b></td>
  <td width="50%"><asp:Label runat="server" id="Frames" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>JavaApplets:</b></td>
  <td width="50%"><asp:Label runat="server" id="JavaApplets" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>JavaScript:</b></td>
  <td width="50%"><asp:Label runat="server" id="JavaScript" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>MajorVersion:</b></td>
  <td width="50%"><asp:Label runat="server" id="MajorVersion" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>MinorVersion:</b></td>
  <td width="50%"><asp:Label runat="server" id="MinorVersion" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>Platform:</b></td>
  <td width="50%"><asp:Label runat="server" id="Platform" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>Tables:</b></td>
  <td width="50%"><asp:Label runat="server" id="Tables" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>Type:</b></td>
  <td width="50%"><asp:Label runat="server" id="Type" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>VBScript:</b></td>
  <td width="50%"><asp:Label runat="server" id="VBScript" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>Version:</b></td>
  <td width="50%"><asp:Label runat="server" id="Version" /></td>
</tr>
<tr class="OddRow">
  <td width="50%"><b>Win16:</b></td>
  <td width="50%"><asp:Label runat="server" id="Win16" /></td>
</tr>
<tr class="EvenRow" bgcolor="skyblue">
  <td width="50%"><b>Win32:</b></td>
  <td width="50%"><asp:Label runat="server" id="Win32" /></td>
</tr>
</table>
</form>
</body>
</html>



打印本文 打印本文  关闭窗口 关闭窗口