Partager via


ASP.NET Browser Registration Tool (Aspnet_regbrowsers.exe) 

The ASP.NET Browser Registration tool parses and compiles all system-wide browser definitions into an assembly and installs the assembly into the global assembly cache. The tool uses the browser definition files (.BROWSER files) from the .NET Framework Browsers subdirectory. The tool can be found in the %SystemRoot%\Microsoft.NET\Framework\version\ directory.

In ASP.NET version 1.1, the Machine.config file contained a section called <browserCaps>. This section contained a series of XML entries that defined the configurations for various browsers based on a regular expression. For ASP.NET version 2.0, a new .BROWSER file defines the parameters of a particular browser using XML entries. You add information on a new browser by adding a new .BROWSER file to the folder located at %SystemRoot%\Microsoft.NET\Framework\version\CONFIG\Browsers on your system.

Because an application is not reading a .config file every time it requires browser information, you can create a new .BROWSER file and run Aspnet_regbrowsers.exe to add the required changes to the assembly. This allows the server to access the new browser information immediately so you do not have to shut down any of your applications to pick up the information. An application can access browser capabilities through the Browser property of the current HttpRequest.

Syntax

aspnet_regbrowsers.exe <options>

Options

Option Description

-?

Displays the Aspnet_regbbrowsers.exe Help text in the command window.

-i

Creates the runtime browser capabilities assembly and installs it in the global assembly cache.

-u

Uninstalls the runtime browser capabilities assembly from the global assembly cache.

Remarks

Browser definition files can be either system-wide or application-specific, and each type is stored in a different location. System-wide browser definition files are stored in the %SystemRoot%\Microsoft.NET\Framework\version\CONFIG\Browsers directory. This directory contains predefined browser definition files that shipped with the corresponding version of the .NET Framework and any additional browser definition files copied there from software updates or service packs. Do not change the predefined browser definition files that come with ASP.NET, because service packs might update those files and overwrite your changes.

Application-specific browser definition files can be placed in the application's App_Browsers directory. In both locations, browser definition files must have a .BROWSER file name extension. Using the ASP.NET Browser Registration tool has no effect on application-specific browser definition files stored in an application's App_Browsers directory.

When browser definition files at the system level are modified, they do not automatically cause an update of browser capabilities for all applications. You must run the ASP.NET Browser Registration tool to update the browser capabilities assembly.

Note

The ASP.NET Browser Registration tool compiles browser definitions in the Browsers directory of the version of the .NET Framework that corresponds to the tool version. Each version of the .NET Framework has its own copy of the tool.

The ASP.NET Browser Registration tool parses and compiles all system-wide browser definitions into an assembly and installs the assembly in the global assembly cache. If there are errors in the system-wide browser definitions, the tool reports those errors. The browser capabilities assembly is used by all Web applications on the system. Note that you can also programmatically recompile system-wide browser definition files by using the BrowserCapabilitiesCodeGenerator class.

Behavior

When the ASP.NET Browser Registration tool runs, a new assembly is created and the effect on all Web applications is the same as if the Machine.config file was changed: All running Web applications are recycled and Microsoft Internet Information Services (IIS) is restarted. The tool also generates a random private token file, and creates a key file to sign the assembly so the assembly can be installed in the global assembly cache. The key file is removed when the tool is finished, leaving only the public key.

At run time, browser definition file information is merged into a collection of known browsers in a BrowserCapabilitiesFactory object. When a request is made, ASP.NET identifies the requesting browser by the request header, and compiles an HttpBrowserCapabilities object that corresponds to the type of the requested browser.

Note

Using the <browserCaps> element in the Web.config file to define browsers is deprecated in the .NET Framework version 2.0, but is still supported. The data in this element is merged with the information from the browser definition files.

By contrast, browser definition files at the application level are automatically parsed and compiled on demand when the application is started. If any changes are made to the application's Browsers directory, the application is automatically recompiled. The ASP.NET Browser Registration tool has no effect on application-level browser information files.

Examples

To parse and compile all system-wide browser definitions into an assembly and install the assembly into the global assembly cache, run Aspnet_regbrowsers.exe. The following command creates and installs the assembly:

C:\WINDOWS\Microsoft.NET\Framework\<versionNumber>\aspnet_regsql.exe -i

You can also use the tool to remove the browser definition assembly from the global assembly cache. The following command removes the browser definitions assembly from the global assembly cache:

aspnet_regsql.exe -u

To get help on using the ASP.NET Browser Registration tool, use the following command:

aspnet_regsql.exe -?

See Also

Tasks

How to: Detect Browser Types in ASP.NET Web Pages

Reference

Browser Definition File Schema (browsers Element)
BrowserCapabilitiesFactory
Browser
HttpCapabilitiesBase

Concepts

ASP.NET Web Server Controls and Browser Capabilities
Securing Browser Definition Files