Search code examples
asp.net-mvc-3http-redirectiis-7.5handlerhttp-status-code-301

custom handler not being called when files don't exist .net mvc 3 IIS 7.5


I just got a custom handler set up to redirect with a 301 response for some old coldfusion page references that I have on my new mvc 3 site. The problem is, I have to actually have the .cfm files on the server for the handler to take effect. If they're not there, my customerrors element is taking over and doing a 404 redirect...when the files are there, works like a peach. My issue is that I'd have to create a boat-load of empty files for the handler to grab them and I'd like for it to just work w/o having the file physically on the machine.

....is this possible? Does the customerrors element always take precedence? Is there a way to override that?

here is my handler node:

<add name="ColdFusionRedirect" path="*.cfm" verb="*" type="MySite.Services.ColdFusionRedirect, MySite" resourceType="Unspecified" />

Edit: it turns out it's not the customErrors node that's taking over, my handler just flat out doesn't work when there is no file...I still get 404s. How can I make this call my custom handler even when files don't exist?


Solution

  • You want to add this to your global.asax RegisterRoutes method:

    routes.IgnoreRoute("{resource}.cfm/{*pathInfo}");