Asp – How to use Custom File Extension instead of .ASPX

asp.net

I want to use custom extension on my web site.
I mean, I do not want to use "default.aspx", i want to use "default.customext"

How could i do this in web.config or anywhere else?

ps: I have no chance to change the asp.net configuration on IIS

I am using .NET Framework 3.5, Visual Studio 2008 sp1, and target Server is IIS 7

thank you

Best Answer

If you're running on IIS7 integrated mode (which I suggest using), you're good to go. Just map the customext to PageHandlerFactory in <system.webServer> section of Web.config.

<system.webServer>
    <handlers>
        <add name="CustomExtensionHandler" 
             path="*.customext" 
             verb="*" 
             type="System.Web.UI.PageHandlerFactory" 
             preCondition="integratedMode" />
    </handlers>
</system.webServer>

IIS7 Classic Mode. Something like:

<system.web>
  <httpHandlers>
     <add path="*.customext" 
         verb="*" 
         type="System.Web.UI.PageHandlerFactory, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </httpHandlers>
</system.web>
<system.webServer>
  <handlers>
     <add name="CustomExtensionISAPI" 
         path="*.customext" 
         verb="*" 
         modules="IsapiModule" 
         scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
  </handlers>
</system.webServer>