1

我正在编写一个程序,其中包含 Visual Studio 2012 提供的 webBrowser 控件。现在我想获取 webBrowser 的版本。我找到了一个 MSDN 的代码示例:

HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls + "<br>");
Response.Write("CDF = " + bc.CDF + "<br>");

但我现在的问题是:我找不到 Request.Browser。它没有被 VS2012 列出。我试图添加一些 .dll 引用,但它仍然不起作用。我希望有人能给我一个有用的提示我应该在哪里看:)

干杯

编辑:我已经得到:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Web;
using System.Web.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Net.Http;
using System.Net;
4

2 回答 2

4

正如您在MSDN 链接中看到的,您正在谈论的请求位于 System.Web 命名空间中。Request通常作为(ASP.Net WebForms) 或(ASP.Net MVC)System.Web.HttpContext.Current.Request的属性或作为属性提供。PageController

但它不会在你的 WinForms 场景中帮助你......

于 2013-08-28T06:47:14.340 回答
0

如果您在 Web 环境中,请尝试以下操作:

HttpRequest request;
string browser = request.Browser.Browser;
于 2013-08-28T06:47:09.883 回答