Map file extension to ASP.Net

I’m converting a site from static HTML to dynamic ASP.Net but I don’t want to rename every page or worry about dropping in pages in the search engines. So I decided to just map HTML files to the ASP.Net processor. I could have sworn that I had done this before and all I had to do was make the normal IIS setting change (http://msdn.microsoft.com/en-us/library/bb515343.aspx). But that just returned a blank page. The fix is to add a buildProvider and an httpHandler.

<configuration>
    <system.web>
        <compilation debug="false">
            <buildProviders>
                <add extension=".html" type="System.Web.Compilation.PageBuildProvider"/>
            </buildProviders>
        </compilation>
        <httpHandlers>
            <add verb="*" path="*.html" validate="false" type="System.Web.UI.PageHandlerFactory" />
        </httpHandlers>
    </system.web>
</configuration>

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.