HTML is What It's About!

I’ve never had to actually utilize the custom extension build provider or http handler in .NET since way way back pre-2.0.  Well that came up again and I went to messing with it and came to the conclusion that it is slightly different now.  What I had to do to get HTML pages to build and render as HTML just like ASPX is below.  Kind of funny trying to get build-able HTML to render HTML?  There is some type of paradox or something there.  doh!

First I added the httpHandler below with the buildProvider.  That was it, nothing else to configure really.  When deploying make sure the server (IIS) handles this correctly.  Other than that, to create *.aspx pages out of *.html pages this is it.

  <compilation debug=”true”>
      <add extension=”.html” type=”System.Web.Compilation.PageBuildProvider” />
    <add verb=”*” path=”*.html” type=”System.Web.UI.PageHandlerFactory” />

Now when you’re creating these HTML / ASPX pages there are a few tricks to simplify things.  First off, don’t select HTML out of the menu of templates when you are creating new pages.  Instead create the *.aspx pages just like you normally would, the difference is, you just rename the file.  That way all of the properly placed markup is in the file for you already, and if you want to select a custom master page you can do so and not have to worry about the markup either.

With some of the things I’m doing with ASP.NET MVC I think this would be a grand idea also, as the restful services, clean paths, and other things are used, developers should also nix the *.aspx extension and just run the things as *.html.  Since really, that is the way it was meant to be, and that is what it’s all about!