Run ASP.NET on Non-Standard Page Extensions

If you have ever wanted to convert an existing HTML-based website to an ASP.NET website, but you didn’t like the idea of losing the “page rank” of those pages, I have the solution. Recently, a friend asked for help on this subject, and since we couldn’t find sufficient information online, I am putting the steps to do this in my blog. In this first case, we wanted to use ASP.NET on long-standing pages that had .html and .htm extensions, but this can apply to all other extensions.

Setup ISAPI Application Mapping

The first step is to tell IIS what system you would like the extension to map to.

  1. Open your existing website in IIS
  2. Browse to the Home Directory tab
  3. Open the Application Settings Configuration (you should see a list of existing application mappings)
  4. Click “Add”
  5. Browse for the .NET Framework you want to use (e.g.: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll)
  6. Enter the extension (such as .htm)
  7. Limit the mapping to specific verbs (e.g. GET,HEAD,POST,DEBUG)
  8. Check Script Engine
  9. Uncheck Check that File Exists
  10. Click OK and close IIS

Note: If you trouble with a greyed out OK box, check out this KB article: http://support.microsoft.com/?id=317948

Update Web.Config with HttpHandlers and BuildProviders

The last step is to update the Web.config for your website so that ASP.NET knows how you want to manage these new extensions. You will first need to add in a new HttpHandler inside of the System.Web node:

<httpHandlers>
<add verb=”*” path=”*.htm” type=”System.Web.UI.PageHandlerFactory”/>
</httpHandlers>

Finally, we will need to add a buildProvider:

<buildProviders>
<add extension=”.htm” type=”System.Web.Compilation.PageBuildProvider”/>
</buildProviders>

Now save the Web.config file and run your ASP.NET -powered, non-standard-extension page!

For more information on BuildProviders, click here

Good luck!

Matt Beckman

Leave a Reply

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