Skip Navigation LinksHome > View Post

XHTML Validator For All

I think most of our regularly readers found this site through the XHTML Validator Module for ASP.NET which we released about a year ago now (and it's still a hot favourite).

You may remember that we got pretty stoked about some of the features promised in IIS7:

"... the ability to now have HttpModules and HttpHandlers participate in all requests to a server..."

"Hopefully, this will mean we can create a new version of our Validator Module that will work with any type of page served by IIS - from plain old HTML to PHP."

(read the original post).

Well, the IIS team didn't let us down. Not only has this feature shipped with IIS7 in Vista, we don't even have to update the Validator Module. It works right out of the box.

If you're not familiar with the Validator Module you may want to check out these posts first:

Let's try it out

Now you're all down with the Validator, all you have to do is drop a copy of the Validator Module dll (Tjoc.Web.Validator.dll) into your web application's bin folder.
In my example the folder isn't even an asp.net web application! It's just a folder in wwwroot with a .htm and a .asp file (remember those?). I just added a bin folder manually.
The new IIS Manager console will even help you configure the module. First you'll need to convert the folder into a web application:

Convert To Application

Next, choose the "Modules" option from the Features View in IIS, this will show you a list of all modules operating on this application (most of the modules you see are inherited from the machine level).

Modules Feature View in IIS7 mmc

To add a new module, simply right click anywhere in the modules view and choose "Add Managed Module".

Adding a Managed Module

Because you have already placed the Tjoc.Web.Validator assembly in your bin folder, the IIS7 console will add any implementations of IHttpModule to the Type dropdown shown in the dialog above (clever eh?). Be sure not to check the "Invoke only for requests to ASP.NET applications or managed handlers" option [1]. This means we can apply our module to every request to our folder, not just extensions configured to invoke aspnet_isapi.dll.

add a dash of configuration

Finally, we need to configure the module. Just add the following to your web.config - notice that the only difference from the configuration file provided in the download is that we've added the .htm and .asp page extensions.

<configSections>
    <section name="validatorModule" type="Tjoc.Web.Validator.ValidatorConfigHandler, Tjoc.Web.Validator"/>
</configSections>

<validatorModule enabled="true" mode="Html">
    <!-- note that we've set up the page extensions we want to validating -->
    <pageExtensions>
        <add value=".htm"/>
        <add value=".asp"/>
    </pageExtensions>
    <contentTypes>
        <add value="text/html"/>
    </contentTypes>
</validatorModule>

An invalid HTM file

An invalid HTM file

A valid ASP Class file

A valid ASP Class file

What a great job the IIS7 team have made of this.

At last the Validator Module can be used with any type of web development - even a static web designer cutting plain old htm can enjoy it.

[1]: it appears the difference between modules configured for all requests and those for just ASP.NET or managed handlers is that the modules are added to a <system.webServer><modules> section rather than the <system.web><httpModules>.

Tags: ASP.NET

 
Josh Post By Josh Twist
3:27 AM
28 Dec 2006

» Next Post: An introduction to the ASP.NET AJAX Extensions
« Previous Post: Copying from Message Boxes

Comments are closed for this post.

Posted by Blake Niemyjski @ 08 Jan 2007 7:52 PM
Great Job

© 2005 - 2014 Josh Twist - All Rights Reserved.