Making the W3C Validator work with ASP.NET

Step 2 – the important one – requires that you create a folder in the root of the web application called App_Browsers and create a file in that folder called w3cvalidator.browser. The contents of this file are as follows.

App_Browsers file:

Browser capability file for the w3c validator  

sample UA: "W3C_Validator/1.305.2.148 libwww-perl/5.803"  
 <browser id="w3cValidator" parentID="default">
     <userAgent match="^W3C_Validator" />

     <userAgent match="^W3C_Validator/(?'version'(?'major'\d+)(?'minor'\.\d+)\w*).*" />

     <capability name="browser" value="w3cValidator" />
     <capability name="majorversion" value="${major}" />
     <capability name="minorversion" value="${minor}" />
     <capability name="version" value="${version}" />
     <capability name="w3cdomversion" value="1.0" />
     <capability name="xml" value="true" />
     <capability name="tagWriter" value="System.Web.UI.HtmlTextWriter" />

If this file isn’t present, for example, your ASP.NET application’s

may have an attribute called "name", an attribute that isn’t valid in the XHTML 1.0 specification.


Now, if you publish your website (which you should be doing in order to put it on a production/public server) the markup generated will be W3C-compliant and will validate properly. Obviously, this assumes that the markup YOU add to your pages complies with W3C recommendations and standards. 🙂