Getting rid of aspx extension?

We’re building a new CMS that tries to do away with any *.aspx ending so that we have prettier URLs that are more “hackable” (Jakob Neilson’s term). In IIS, we route all requests through ASP.NET and then impliment a StaticFileHandler for images, css, javascript, etc. and a custom HandlerFactory to build our pages from the DataStore. But doing this means that all *.aspx, *.ashx, and *.asmx files no longer work.

To re-enable *.aspx, *.ashx, and *.asmx, and ASP.NET 2.0 AssemblyResources, just add the following lines to your web.config:

<httpHandlers>
<add path=”WebResource.axd” verb=”GET” type=”System.Web.Handlers.AssemblyResourceLoader” validate=”true”/>
<add path=”*.aspx” verb=”*” type=”System.Web.UI.PageHandlerFactory” />
<add path=”*.asmx” verb=”*” type=”System.Web.Services.Protocols.WebServiceHandlerFactory” />
<add path=”*.ashx” verb=”*” type=”System.Web.IHttpHandlerFactory” />
<add verb=”*” path=”*” type=”YourNamespace.YourCustomHandlerFactory, YourAssemblyName”/>
</httpHandlers>

This really just shows the classes that impliment IHttpHandlerFactory which makes things a million times easier than in ASP.NET 1.x.

1 thought on “Getting rid of aspx extension?

Comments are closed.