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

无人久伴 提交于 2019-12-08 12:22:52

问题


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?


回答1:


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

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



来源:https://stackoverflow.com/questions/7905405/custom-handler-not-being-called-when-files-dont-exist-net-mvc-3-iis-7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!