Software to help you build a better store
SEARCH
June 12, 2005

How to make ASP.NET HTML identical in Internet Explorer and FireFox

ASP.NET server tags such as <asp:Panel> are rendered differently by the server depending on the capabilities of the browser. ASP.NET categorizes browsers as uplevel or downlevel. ASP.NET will render the <asp:Panel> tag as an HTML <div> tag on uplevel browsers and as a <table> tag on downlevel browsers.

As you can imagine, this can make CSS jockies very frustrated.

ASP.NET uses the <browserCaps> section of the machine.config or web.config file to determine if a browser is uplevel or downlevel. Every browser identifies itself with a request header that looks like this:

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 1.1.4322.2032)

ASP.NET matches the header using a regular expression to an entry in <browserCaps> to determine the browser capabilities. Unfortunately, the <browserCaps> that ships with ASP.NET 1.1 does not include entries for many modern and very capable browsers including FireFox and Safari. Luckily, clever people have created new <browserCaps> entries that you can add to your web.config file. These new <browserCaps> entires will cause ASP.NET to render the server controls in exactly the same way for Internet Explorer, FireFox and Safari.

Use the links below to switch between a version of a test page rendered with the new <browserCaps> and without the new <browserCaps>. Use the View Source option of your browser to examine the HTML that is generated. Notice that with the new <browserCaps>, the <asp:Panel> is rendered as a <div> in Internet Explorer, FireFox, and Safari. Without the new <browserCaps>, the <asp:Panel> is rendered as a <table> in FireFox and Safari.

with <BrowserCaps> without <BrowserCaps>.

This site looks much better in a browser that supports current web standards, but it is accessible to any browser. Download one now This link is to a third party web site which will open in a new window

Some parts of this site will not work effectively on this older browser.
Please consider updating your browser This link is to a third party web site which will open in a new window

SSL