CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo [MVP]

Software management consultant and CTO, Headspring Systems

How to render up-level html to FireFox from ASP.NET 1.1 - level 200

Out of the box, ASP.NET 1.1 doesn't recognize FireFox, but FireFox is now probably the second most popular browser behind IE.  IE still has the market, and if you are just checking IE, you probably won't feel any pain, but when developing an app for the Internet, you should make sure that your site works and looks good in the popular browsers. 

Since ASP.NET 1.1 doesn't recognize FireFox, the built-in WebControls will render down-level html.  What that means is that every <div/> tag will be replaced by a single-cell table, and a host of other changes.  This isn't good because it will distort the layout of your page.

The good news is that ASP.NET 1.1 can easily be told of the capabilities of other browsers through the web.config file.  You can customize the regular expression used to evaluate the User Agent string, but if you quickly need to support FireFox as well as IE, paste the following into your web.config within the <system.web/> node:

    <browserCaps>
            <case match="^Mozilla/5\.0 \([^)]*\) (Gecko/[-\d]+)(?'VendorProductToken' (?'type'[^/\d]*)([\d]*)/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)))?">
                browser=Gecko
                <filter>
                    <case match="(Gecko/[-\d]+)(?'VendorProductToken' (?'type'[^/\d]*)([\d]*)/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)))">
                        type=${type}
                    </case>
                    <case> <!-- plain Mozilla if no VendorProductToken found -->
                        type=Mozilla
                    </case>
                </filter>
                frames=true
                tables=true
                cookies=true
                javascript=true
                javaapplets=true
                ecmascriptversion=1.5
                w3cdomversion=1.0
                css1=true
                css2=true
                xml=true
                tagwriter=System.Web.UI.HtmlTextWriter
                <case match="rv:(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*))">
                    version=${version}
                    majorversion=0${major}
                    minorversion=0${minor}
                    <case match="^b" with="${letters}">
                        beta=true
                    </case>
                </case>
            </case>
        </browserCaps>



Comments

reteep said:

Hi Jeffrey,

I'm just curious if this counts for ASP.NET 2.0, too?

Thanks!
# June 30, 2005 5:24 AM

Jeffrey Palermo said:

I haven't explicitly tested it, but I've very confident that 2.0 knows about FireFox. Within a few months I'll be converting an app to 2.0, so I'll post my experiences.
# June 30, 2005 5:47 AM

Zhaph said:

Check out:
http://slingfive.com/pages/code/browserCaps/

This has a fairly complete overhaul of the Browser Caps section that includes a host of other browsers as well (Opera, Safari, etc).
# July 1, 2005 1:51 AM

Steve Reddoch said:

Hi,

This seems to work - sorta, but I have a bunch of stuff on my web site (www.ontime-technologies.com) that still does not render correctly. Any ideas?

sreddoch@ontime-technologies.com

thanks!
# July 11, 2005 7:50 PM

Jeffrey Palermo said:

As I mentioned before, I'm at a new company, and I'm one of the .Net developers working on Shadows.com.&amp;nbsp;...
# July 19, 2005 12:56 PM

Rahul said:

Only first page getting displayed with links are not working.We have frames on default page they are not getting displayed.

# January 9, 2008 3:05 PM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication