Last post Jul 27, 2010 11:53 AM by greensombrero
Jul 26, 2010 03:31 PM|greensombrero|LINK
I have an interesting scenario. Here is what I want to do:
1. Map all requests to a custom IHttpHandlerFactory implementation. This is easy enough to do by setting up a * mapping.
2. Have requests for .aspx though still go through the default PageHandlerFactory (I think that is what it is called), basically be handled as normal.
Is this possible in ASP.NET 4 using IIS 7?
My use case is that we are building an RESTful application of sorts that will be serving data back in different formats based on the file extension specified on the url. So for example .xml will be an xml format of the data while html serves an html format.
We are using an MVC framework to accomplish this and have this piece all figured out.
The problem is that we need to have some legacy aspx web form pages integrated with the application. If I just set up a * mapping to our custom IHttpHandlerFactory they won't work and I need to figure out some way around that.
Thanks for any help you can provide,
Jul 27, 2010 11:53 AM|greensombrero|LINK
In messing around I've determined that if I add the following to the httpHandlers section it appears to do what I want:
<add path="*.aspx" verb="*" type="System.Web.UI.PageHandlerFactory" validate="True" />
<add path="*" type="CustomHandler" verb="*" validate="false"/>
I'm not all that familiar with how ASP.NET's config system works I know it inherits settings from machine.config and the master web.config. I'm wondering if this is expected behavior and if it is safe to rely on it or if there is a reason this won't work.
I've only tested it from the built in Visual Studio web server. I intend to deploy to a 2008 R2 server and double check everything works right there as well.