Adding W3C Validation to WebMatrix

WebMatrix Doing W3C Validation ReportingOne of the extremely cool features with IIS Developer Express is that you can extend it with the same modules you’d extend IIS7.5 with.  Examples of popular modules are the IIS SEO Toolkit, FastCGI and WinCache.

Which are all included already.   I’ve been looking for a module to add to it as an example that would bring value to web developers and came across a great post in Carlos Aguilar Mares blog titled: IIS SEO Toolkit and W3C Validation Service and I thought, That’s it!  That’s a feature we could extend WebMatrix with that would bring value to web developers within the WebMatrix tool that is a perfect fit for the dev environment WebMatrix provides you. 

 

How Carlos did it for IIS Servers

First if you haven’t visited Carlos’s blog, I recommend you do so (it’s another of the awesome IIS blogs).  His article: IIS SEO Toolkit and W3C Validation Service talks about a sample project he created that basically takes your web content, runs it through the W3C HTML5 markup validation service and then returns a report of errors and warnings.   The article was written around the current version of the IIS SEO Toolkit available for production, assumes you’re installing it on an IIS7 server and that you’re using the same version of IIS SEO Toolkit he’s using. 

Unfortunately, we’re not using the same version of the IIS SEO Toolkit and not installing it on an IIS7 server but he was kind enough to give us the source so we’re good to go!

 

WARNING: In no way should I be confused as a professional programmer. I don’t know what I’m doing and if you follow the instructions from this point forward, proceed at your own risk.

How to add Carlos’s Extension to WebMatrix

We’re going to take 4 steps:

  1. Convert the project to .NET 4.0 (VS2010 does this for us)
  2. Recompile the DLL to use the same binaries for the Microsoft.Web.Management.SEO.Client and Microsoft.Web.Management references.
  3. Add the new DLL to the GAC
  4. Add a reference to the new DLL in the administration.config file for IIS Developer Express.

1. Converting the project to .NET 4.0.

This was the easy part. You’ll download the project, open it in VS2010, let it convert the project to VS2010 and then just go to Project –> SEOW3Validator Properties and change the Target framework.

Change Your Framework

While we’re in here, you should also update the Build Events. Carlos has it set to register the new DLL in the GAC and that’s throwing an error for me so I just removed the line by going to Build Events –> ‘Post-build event command line’ and removing the code in that box.

2. Update References and Recompile the DLL

There’s a reference to Microsoft.Web.Management and Microsoft.Web.Management.SEO.Client as shown below

Update your references

We’ll delete those two references and then we’ll copy over these two DLL’s from our WebMatrix install, they can be found in:

“C:\Program Files (x86)\Microsoft WebMatrix”

(I actually copied over all of the Microsoft.Web.Management.* dll’s when I did mine)

once you’ve added these references back in pointing to the DLL’s where you downloaded them to (I put them in the project root folder and then just used the browse option to find them:

Update your references

Then I recompiled the project and it compiled with 3 warnings all related to Microsoft.Web.Management.SEO.Crawler.Violation.Violation being obsolete.. but they were warnings and it compiled! WORKS FOR ME!

3. Add the new DLL to the GAC.

I used xcopy for this. I created a new folder:

C:\Windows\assembly\GAC_MSIL\SEOW3Validator\1.0.0.0__995ee9b8fa017847

and copied the DLL I just created to there. Only the SEOW3Validator DLL I created. If you don’t want to create this DLL yourself, you’re welcome to download the one I compiled, but you’re using it at your own risk and if you break something, blow up your computer or cause nuclear fallout, it’s your own fault for listening to me!

My DLL can be downloaded from here: SEOW3Validator-Jess.zip.

4. Add a reference in the Modules section of the administration.config file

This file can be found in:

C:\Program Files (x86)\Microsoft WebMatrix\config

You’ll open it up, look for the line: </moduleProviders> and just before that line, add this:

<add name="SEOW3Validator" 
       type="SEOW3Validator.SEOW3ValidatorModuleProvider, SEOW3Validator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=995ee9b8fa017847" />

and then save the file.

That’s it, Let’s see it in action!

Now all we have to do is fire up WebMatrix, go to one of our projects and then run an SEO report just like we’d normally do:

Run an SEO report

This fires up our site in IIS Developer Express and then sends each of the pages over to the W3C Validator a page at a time with a 1.5second delay between each page. After it’s done you’ll see the SEO report including the W3 Validator errors and warnings:

Marvel at it's awesomeness!

Yes, it's truly awesome!

Where do we go from here?

Well hopefully someone finds this useful and takes up the project to extend it even further. I’d love to see this type of extension made a part of the WebMatrix tool actually, I think it’s a perfect component for it.

I hope you found my little article helpful. I’ve seen a lot of comments about WebMatrix and how it’s geared towards being a project for non-coders, noobs and ‘hobbyists’ (and most say how it is going to fail) but I don’t think that’s the case at all! Although it will allow that class of developers to use the tools and build a better web, it’s going to be equally useful for the seasoned developer.  Best of all, it’s going to be useful for you whether you build your sites in custom .NET, custom PHP, in the new ASP.NET Web Pages or based off of open source applications like WordPress and DotNetNuke.

As I mentioned, I’m not a professional programmer but I considering programming (be it PHP, C#, VB, Perl, Bash Shell) a tool for the toolbox and I think if you’re a professional developer or designer WebMatrix should be another tool in your toolbox because it’s certainly one in mine!

author avatar
Jess
With a background in web development and web server administration dating back to 1994, Jess Coburn founded Applied Innovations in 1999. As CEO, he led the company to become a recognized leader in Windows Hosting, specializing in ASP.NET, E-Commerce, and advanced web application hosting. Under Jess's leadership, Applied Innovations became known for making cutting-edge technology accessible and affordable for businesses. Building on this success, Jess expanded his vision by founding QIT Solutions, a managed cloud, IT, and cybersecurity company, where he continues to leverage his extensive industry experience to deliver innovative and secure IT solutions to businesses.

Leave a Comment

Scroll to Top