views:

661

answers:

4

I need my .net application to use the .html extension instead of .aspx

I'm converting a php app and there are external applications which depend on that extension to function.

What is the best way to do this?

Thanks

+1  A: 

You want to use httpHandlers

dove
A: 

Note that I am not 100% sure this will work with the PHP extension, we are using this procedure for a custom extension here.

You can change the IIS configuration: Open the IIS Console (right click on My Computer > Manage... > Services and applications)

  • If you are in a website, open the websites properties and the "Home directory" tab.
  • If you are in a virtual directory, the properties then the "Virtual Directory" tab.

Click The "Configuration Button", look up the .aspx extension and use the same configuration for the ".php" extension (tip: you can copy paste the executable dll name between both dialogs)

Luk
+3  A: 

In IIS, when you create the application for the virtual directory, click on "Configuration" for the application, and edit "App mappings", i.e. add a new mapping for html.

Or, in your web.config, in add this sections:

<httpHandlers>
   <remove verb="*" path="*.html" />
   <add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers>
<compilation>
   <buildProviders>
       <buildProvider 
           extension=".html" 
           type="System.Web.Compilation.PageBuildProvider" />
   </buildProviders>
</compilation>

EDIT: Added the section, according to the comment. Thanks Chris.

Sunny
Close, but I'm receiving the following error: There is no build provider registered for the extension '.html'
Chris Lively
Your solution worked once I added the following: <buildProviders> <add extension=".html" type="System.Web.Compilation.PageBuildProvider" /> </buildProviders>
Chris Lively
A: 

Some time ago, we migrated a web application from coldfusion to PHP, and had to preserve the old URLs. The way we did it was to use mod_rewrite to rewrite .cfm URLs to .php ones. Perhaps you can do something similar?

Simon