ASP.NET Web Server Controls and Browser Capabilities
Different browsers, and different versions of the same browser, support different features. ASP.NET server controls will automatically determine the browser that has requested the page and render the appropriate markup for that browser. However, some control features cannot be rendered on older browsers, so it is a good idea to look at the output of your pages on as many browser types as you can to make sure that the pages are presented to all browsers the way you want them to be.
By default, ASP.NET determines browser capabilities by reading the user-agent information that is passed from the browser to the server during a request. It compares the user-agent string that is received from the browser to user agent strings that are stored in browser definition files. These browser definition files contain information about the capabilities of various user agents. When ASP.NET finds a match between the current user-agent string and a user-agent string in a browser definition file, it loads the corresponding browser capabilities into the HttpBrowserCapabilities object. The properties of the HttpBrowserCapabilities object can then be used to determine whether the browser type that is represented by the user agent supports scripting, styles, frames, and so on. Based on these capabilities, the controls on the page render Web controls using appropriate markup.
The HttpBrowserCapabilities object is available in the Browser property of the HttpRequest object. You can access information about some of the browser capabilities in strongly-typed properties of the HttpBrowserCapabilities object. Other capabilities are defined only in the browser definition files and are available only as entries in a dictionary collection.
If the browser that is making the request is Internet Explorer 8, the jsVersion string will contain the value "1.5".
To determine whether the request originated from a mobile device, you can use the IsMobileDevice property, as shown in the following example:
ASP.NET stores the default browser definition files in the following folder:
The browser definition files were updated for ASP.NET 4, and the new versions are not backward compatible with browser definition files that were provided with earlier versions of ASP.NET For more information, see How to: Upgrade an ASP.NET Web Application to ASP.NET 4.
You can define custom browser types by creating new browser definition files and adding them to the ASP.NET Browsers folder or to the App_Browsers folder of a Web site. If you update or add browser definition files to the ASP.NET Browsers folder, you must run the aspnet_regbrowsers.exe tool.
The browserCaps section of configuration files (.config) is deprecated. For backward compatibility with ASP.NET 1.1, the configuration settings in the browserCaps section are still effective if they are set at the application level. However, the settings are merged with the information from the machine-level browser definition files and any application-level App_Browser folders. For more information, see Browser Definition File Schema (browsers Element).
If you want to explicitly control how the page is rendered instead of relying on automatic browser detection, you can set the page's ClientTarget property. You can set the property declaratively as an attribute of the @ Page directive for that page, or you can set it programmatically.
The value of the ClientTarget property is an alias for the type of browser you want to render the page for. For example, if you want to see how a page would render on Apple iPhone without using an emulator, you could create an alias for iPhone and set the ClientTarget property to that alias. The alias that you specify must be defined in the clientTarget section of the configuration file. The predefined defaults are uplevel and downlevel.
You can create additional aliases by defining them in the root Web.config file or in the application Web.config file. For more information, see clientTarget Element (ASP.NET Settings Schema).
Ajax-enabled features in ASP.NET are compatible with most modern browsers and run with the default security settings for these browsers. These controls and features require that the browser be able to run client script. The UpdatePanel and ScriptManager controls are examples of Ajax-enabled controls. For a list of compatible browsers and of recommended security settings for Ajax-enabled controls and features, see Browser Security Settings for Ajax Enabled ASP.NET Pages.
For an overview of Ajax features in ASP.NET, see Microsoft Ajax.
Some functionality of ASP.NET server controls depends on being able to run client script. The client script is automatically generated and sent as part of the page, if the browser is capable of executing script. Even so, some users might have turned off script execution in their browsers, and will therefore not be able to fully use the control's capabilities. For more information, see Client Script in ASP.NET Web Pages.