Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework General Reference
browserCaps Element (ASP.NET Settings Schema)

Specifies the settings of supported browsers and the capabilities of the supported browsers. The browserCaps element can be updated as required to specify new browsers and capabilities.

NoteNote:

Using the browserCaps element in the Web.config file to define browsers is deprecated in the .NET Framework 2.0, but it is still supported. The data in this element is merged with the information from the browser definition files (.browser) that is located in the machine-level %SystemRoot%\Microsoft.NET\Framework\version\CONFIG\Browsers folder and any existing application-level App_Browser folders. For more information, see Browser Definition File Schema (browsers Element).

configuration Element (General Settings Schema)
  system.web Element (ASP.NET Settings Schema)
    browserCaps Element (ASP.NET Settings Schema)
<browserCaps>
   <result />
   <use />
   [browser capability property assignments]
   <filter>...</filter>
</browserCaps>

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

userAgentCacheKeyLength

Optional String attribute.

Specifies the length of the browser identification string to use as the key for caching browser capabilities objects in the internal cache. For more information about browser capabilities objects, see Browser Definition File Schema (browsers Element).

This attribute is new in the .NET Framework version 2.0.

The default is "64".

Child Elements

Element

Description

filter

Optional element.

Specifies a list of search strings that allow you to apply individual settings to specific browser definitions.

result

Specifies the HttpCapabilitiesBase-derived class that is used to hold the results from parsing the browserCaps section. The capabilities are stored as key/value string pairs for each browser.

This element still applies in the .NET Framework version 2.0.

use

Specifies the HTTP request string to use to parse the browser capability information that is stored in the filter and case elements.

Parent Elements

Element

Description

configuration

Specifies the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file and contains configuration elements that configure ASP.NET Web applications and control how the applications behave.

The browserCaps element specifies the settings of supported browsers and the capabilities for the supported browsers. The browserCaps element can be updated as required to specify new browsers and capabilities.

For a list of valid browser properties, see HttpBrowserCapabilities.

Lines of the form capsVariableName=regular expression are assignments. Use the syntax %{capsVariableName} or ${captureGroupName} in match attributes and on the right side of assignments.

For more information about how to use regular expressions, see .NET Framework Regular Expressions. For the full browserCaps section, with a complete example of this syntax, see the Machine.config file that is installed with the .NET Framework.

The name/value pairs that are captured with capsVariableName can be accessed through the Item property of the HttpBrowserCapabilities object that is inherited from the HttpCapabilitiesBase class. The Item property is the default indexer property in C#.

Default Configuration

In the .NET Framework version 2.0, the following limited default browserCaps element is configured in the root Web.config file because it is deprecated in favor of using browser definition files to specify supported browsers and capabilities. For more information, see Browser Definition File Schema (browsers Element).

<browserCaps userAgentCacheKeyLength="64">
   <result 
      type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
   />
</browserCaps>

In the .NET Framework versions 1.0 and 1.1, the default browserCaps element that is configured in the machine.config file is too large to list here. For updates to the browser data go to http://www.cyscape.com/browsercaps. Periodic device updates replace this browser capabilities section.

The following code example demonstrates how to parse the User-Agent HTTP header for any version of Microsoft Internet Explorer, as long as the format of the User-Agent string remains approximately unchanged.

The example uses .NET Framework Regular Expressions and the ability of regular expressions to capture subexpressions in order to move version numbers directly from the User-Agent string to the HttpBrowserCapabilities object.

The file specifies name/value pairs in the form of assignment statements, which is similar to Microsoft Internet Information Services (IIS) browscap.ini files. For example, the line "browser=IE" sets the value of the browser field to the string "IE".

<configuration>
 <system.web>
   <browserCaps>
      <result type="System.Web.HttpBrowserCapabilities, System.Web"/>
      <use var="HTTP_USER_AGENT"/>
      browser=Unknown
      version=0.0
      majorversion=0
      minorversion=0
      frames=false
      tables=false
      cookies=false
      backgroundsounds=false
      <filter>
    <case match="^Mozilla[^(]*\(compatible; MSIE 
       (?'ver'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*))
       (?'extra'.*)">
       browser=IE
       version=${ver}
       majorver=${major}
       minorver=${minor}
       <case match="^2\." with="%{version}">
          tables=true
          cookies=true
          backgroundsounds=true
          <case match="2\.5b" with="%{version}">
        beta=true
          </case>
       </case>
    </case>
      </filter>
   </browsercaps>
 </system.web>
</configuration>

Configuration section handler

HttpCapabilitiesSectionHandler

Configuration member

Browsers()()()

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 2.0 (deprecated), 1.1, or 1.0

Microsoft Visual Studio 2003 or Visual Studio 2005

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
BrowserCaps are not updated by Cyscape      Zhaph ... Thomas Lee   |   Edit   |   Show History
Please stop referring to http://www.cyscape.com/browsercaps as a repository of updated browser caps files - I don't think I've ever seen them actually host a browsercaps update - that page has always (for the last 7 years or so) tried to sell you BrowserHawk, their own Browser sniffing application.

For those of you still using 1.1, I would suggest that you take a look at http://owenbrady.net/browsercaps/ - this has a fairly up to date list, although I'm currently having some issues with the Office Live Connector additions to my user agent string for IE (7 and 8 are considered downlevel).
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker