Professional Documents
Culture Documents
NET 4
ASP.NET 4 has been updated to include information for modern browsers and devices. You can now use ASP.NET 4 to detect features of the following browsers and devices: Microsoft Internet Explorer 6, 7, 8 Google Chrome Mozilla Firefox 3, 3.5 Apple Safari 3, 4 Opera 8, 9, 10 IPhone, IPod Blackberry Windows Mobile
To improve performance, information for older browsers and devices was removed. For example, ASP.NET 4 no longer includes browser information for Netscape Navigator or versions of Internet Explorer older than Internet Explorer 6.0. This article explains how you can use the new browser capabilities files with earlier versions of ASP.NET such as ASP.NET 3.5. This article also explains how you can revert to using the ASP.NET 3.5 browser files with ASP.NET 4.
Each browser definition file contains a set of browser definitions. For example, the firefox.browser file contains browser definitions for Firefox 3 and Firefox 3.5. You can learn about the structure of a browser definition file by reading the following article located at the MSDN website: http://msdn.microsoft.com/en-us/library/ms228122.aspx The HttpBrowserCapabilities object exposed by the Request.Browser property -uses these browser definition files both to detect and to return information about the capabilities of different browsers. For example, you can check the Request.Browser.Cookies property to detect whether the current browser supports browser cookies. Web controls, such as the Menu and TreeView controls, use browser capabilities information to adaptively render different script and markup for different types of browsers. For example, the experience of using a TreeView control with a browser that does not support JavaScript is different than the experience of using a TreeView with a browser that does support JavaScript.
2. Open the Visual Studio 2008 Command Prompt (or the Visual Studio 2005 Command Prompt) and execute the following command:
aspnet_regbrowsers i
3. Perform a Rebuild of your Visual Studio project by selecting the menu option Build, Rebuild. After you complete these steps, your ASP.NET application will use the new browser definition files.
2. Open the Visual Studio 2010 Command Prompt and execute the following command:
aspnet_regbrowsers i
3. Perform a Rebuild of your Visual Studio project by selecting the menu option Build, Rebuild. After you complete these steps, your ASP.NET 4 applications will use the original browser definition files used with ASP.NET 3.5 and earlier versions of ASP.NET.
If you open the page using Microsoft Internet Explorer 8, and you are using the new browser definition files, then you will see the identifier ie8. Otherwise, if your application is using the older browser definition files, then you will seethe identifier ie6to9.
Summary
In this article, you learned how you can use the ASP.NET 4 browser definition files with earlier versions of ASP.NET. By taking advantage of the updated browser files, you can detect recent browsers such as Google Chrome and the IPhone. You also learned how you can revert back to the old browser definitions files when building ASP.NET 4 Web applications. If you encounter backwards compatibility issues when upgrading from ASP.NET 3.5 to ASP.NET 4, you can revert back to the earlier behavior.