huseyin
huseyin

Reputation:

How to use Custom File Extension instead of .ASPX

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

Upvotes: 2

Views: 3756

Answers (4)

Josh
Josh

Reputation: 6322

If you can get ISAPI rewrite installed you can 'rewrite' your pages.

Upvotes: 0

TonyCool
TonyCool

Reputation: 1004

You can use the following configuration in Helicon Ape mod-rewrite:

RewriteBase /
RewriteRule ^default\.customext$ default.aspx [NC,L]

Upvotes: 0

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422310

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>

Upvotes: 9

Dan
Dan

Reputation: 17445

Take a look at this StackOverflow question for doing this in IIS6: ASP.NET - IIS Custom Mapping Extensions - How?

Upvotes: 1

Related Questions