Fixing the Browser Capabilities Detection in ASP.NET

ASP.NET 1.1 ships with now pretty outdated browser capabilities detection settings. We ran into the problem that my colleague Chi Wai Man blogged about: ASP.NET uses the System.Web.UI.Html32TextWriter instead of the System.Web.UI.HtmlTextWriter for rendering HTML to FireFox.

ASP.NET uses the browserCaps section in the machine.config file for determining what the capabilites of a browser are. I found an updated version of these settings from Rob Eberhardt but those were not complete. I merged those settings with what was already present in the default machine.config. You can find a part of the result below or download it here. I will publish the complete  browserCaps section next week.

Note that I didn't update any of the mobile devices stuff, so this will still be very outdated.

[Update 2005-08-07: Added the link to the source of the browserCaps section. Fixed a typo and some layout issues. Removed download link because it didn't work (files with .config extension cannot be downloaded).]

<browserCaps>
<filter>
<!-- Internet Explorer //-->
<case match="^Mozilla[^(]*(compatible; MSIE (?'version'(?'major'd+)(?'minor'.d+)(?'letters'w*))(?'extra'.*)">
browser=IE
version=${version}
majorversion=${major}
minorversion=${minor}
<case match="^[5-9]." with="${version}">
frames=true
tables=true
cookies=true
backgroundsounds=true
vbscript=true
javascript=true
javaapplets=true
activexcontrols=true
tagwriter=System.Web.UI.HtmlTextWriter
ecmascriptversion=1.2
msdomversion=${major}${minor}
w3cdomversion=1.0
css1=true
css2=true
xml=true
isMobileDevice="true"
<filter with="${letters}" match="^b">
beta=true
</filter>
<filter with="${extra}" match="Crawler">
crawler=true
</filter>
</case>
<case match="^4." with="${version}">
frames=true
tables=true
cookies=true
backgroundsounds=true
vbscript=true
javascript=true
javaapplets=true
activexcontrols=true
tagwriter=System.Web.UI.HtmlTextWriter
ecmascriptversion=1.2
msdomversion=4.0
cdf=true
css1=true
<filter with="${letters}" match="^[ab]">
beta=true
</filter>
<filter with="${extra}" match="Crawler">
crawler=true
</filter>
<filter match="; AOL" with="${extra}">
aol=true
</filter>
<filter match="; Update a;" with="${extra}">
authenticodeupdate=true
</filter>
</case>
<case match="^3." with="${version}">
frames=true
tables=true
cookies=true
backgroundsounds=true
vbscript=true
javascript=true
javaapplets=true
activexcontrols=true
ecmascriptversion=1.0
css1=true
<filter match="true" with="%{win16}">
javaapplets=false
activexcontrols=false
<filter match="^a" with="${letters}">
beta=true
vbscript=false
javascript=false
</filter>
</filter>
<filter match="Mac68K|MacPPC" with="%{platform}">
vbscript=false
activexcontrols=false
</filter>
<filter match="^B" with="${letters}">
beta=true
</filter>
<filter match="; AK;" with="${extra}">
ak=true
</filter>
<filter match="; SK;" with="${extra}">
sk=true
</filter>
<filter match="; Update a;" with="${extra}">
authenticodeupdate=true
</filter>
<filter match="; AOL" with="${extra}">
aol=true
</filter>
</case>
<case match="^2." with="${version}">
tables=true
cookies=true
backgroundsounds=true
<filter match="^b" with="${letters}">
beta=true
</filter>
<filter match="; AOL" with="${extra}">
aol=true
</filter>
</case>
<case match="^1.5" with="${version}">
tables=true
cookies=true
</case>
</case>
<!-- Opera //-->
<case match="Opera[ /](?'version'(?'major'd+)(?'minor'.(?'minorint'd+))(?'letters'w*))">
browser=Opera
version=${version}
majorversion=${major}
minorversion=${minor}
frames=true
tables=true
cookies=true
javascript=true
ecmascriptversion=1.1
<filter match="[4-9]" with="${major}">
ecmascriptversion=1.3
css1=true
css2=true
xml=true
<filter match="[5-9]" with="${major}">
w3cdomversion=1.0
</filter>
</filter>
<filter match="[7-9]" with="${major}">
tagwriter=System.Web.UI.HtmlTextWriter
</filter>
<filter>
<case match="7" with="${major}">
<filter>
<case match="[5-9]" with="${minorint}">
ecmascriptversion=1.5
</case>
<case>
ecmascriptversion=1.4
</case>
</filter>
</case>
<case match="[8-9]" with="${major}">
ecmascriptversion=1.5
</case>
</filter>
<filter match="^b" with="${letters}">
beta=true
</filter>
</case>
<!-- Pocket Internet Explorer //-->
<case match="^Microsoft Pocket Internet Explorer/0.6">
browser=PIE
version=1.0
majorversion=1
minorversion=0
tables=true
backgroundsounds=true
platform=WinCE
isMobileDevice="true"
</case>
<case match="^Mozilla[^(]*(compatible; MSPIE (?'version'(?'major'd+)(?'minor'.d+)(?'letters'w*))(?'extra'.*)">
browser=PIE
version=${version}
majorversion=${major}
minorversion=${minor}
tables=true
backgroundsounds=true
cookies=true
isMobileDevice="true"
<case match="2." with="${version}">
frames=true
</case>
</case>
<!-- GECKO Based Browsers (Netscape 6+, Mozilla/Firefox, ...) //-->
<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>
<!-- Older Mozilla browsers //-->
<case match="^Mozilla/2.01 (Compatible) Oracle(tm) PowerBrowser(tm)/1.0a">
browser=PowerBrowser
version=1.5
majorversion=1
minorversion=.5
frames=true
tables=true
cookies=true
vbscript=true
javascript=true
javaapplets=true
platform=Win95
</case>
<case match="^Mozilla/(?'version'(?'major'd+)(?'minor'.d+)(?'letters'w*)).*">
browser=Netscape
version=${version}
majorversion=${major}
minorversion=${minor}
<filter match="^b" with="${letters}">
beta=true
</filter>
<filter match="Gold" with="${letters}">
gold=true
</filter>
<case match="^[4-9]." with="${version}">
frames=true
tables=true
cookies=true
javascript=true
javaapplets=true
ecmascriptversion=1.2
css1=true
<filter match="^[5-9]*" with="${minor}">
ecmascriptversion=1.3
</filter>
</case>
<case match="^[2-3]." with="${version}">
frames=true
tables=true
cookies=true
javascript=true
javaapplets=true
ecmascriptversion=1.1
</case>
</case>
<!-- AppleWebKit Based Browsers (Safari...) //-->
<case match="AppleWebKit/(?'version'(?'major'd?)(?'minor'd{2})(?'letters'w*)?)">
browser=AppleWebKit
version=${version}
majorversion=0${major}
minorversion=0.${minor}
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="AppleWebKit/(?'version'(?'major'd)(?'minor'd+)(?'letters'w*))(.* )?(?'type'[^/d]*)/.*( |$)">
type=${type}
</case>
</case>
<!-- Konqueror //-->
<case match=".+[K|k]onqueror/(?'version'(?'major'd+)(?'minor'(.[d])*)(?'letters'[^;]*));s+(?'platform'[^;)]*)(;|))">
browser=Konqueror
version=${version}
majorversion=0${major}
minorversion=0${minor}
platform=${platform}
type=Konqueror
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>
<!-- Web TV //-->
<case match="WebTV/(?'version'(?'major'd+)(?'minor'.d+)(?'letters'w*))">
browser=WebTV
version=${version}
majorversion=${major}
minorversion=${minor}
tables=true
cookies=true
backgroundsounds=true
isMobileDevice="true"
<filter match="2" with="${minor}">
javascript=true
ecmascriptversion=1.0
css1=true
</filter>
<filter match="^b" with="${letters}">
beta=true
</filter>
</case>
</filter>
<filter>
<case match="Unknown" with="%{browser}">
type=Unknown
</case>
<case>
type=%{browser}%{majorversion}
</case>
</filter>
</browserCaps>

One thought on “Fixing the Browser Capabilities Detection in ASP.NET

  1. Unfortunately I had some trouble publishing the article Friday and forgot to link to the source of part of updated browserCaps section. It is the same source as referenced by the article Mischa mentions. I will update the post to include the link and will try to fix some formatting and download issues.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *