文件不存在时未调用自定义处理程序.net mvc 3 IIS 7.5 [英] custom handler not being called when files don't exist .net mvc 3 IIS 7.5

查看:210
本文介绍了文件不存在时未调用自定义处理程序.net mvc 3 IIS 7.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚设置了一个自定义处理程序,以301响应重定向到我在新的mvc 3站点上获得的一些旧的Coldfusion页面引用.问题是,我必须在服务器上实际具有.cfm文件,处理程序才能生效.如果它们不存在,则我的customerrors元素将接管并执行404重定向...当文件在那里时,其作用就像桃子一样.我的问题是,我必须为处理程序创建一大堆空文件以抓取它们,并且我希望它可以不带物理文件就可以在机器上正常工作.

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.

....这可能吗? customerrors元素始终优先吗?有没有办法覆盖它?

....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" />

事实证明不是customErrors节点在接管,当没有文件时,我的处理程序无法正常工作……我仍然得到404.即使文件不存在,如何将其称为我的自定义处理程序?

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?

推荐答案

您要将其添加到global.asax RegisterRoutes方法:

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

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

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

这篇关于文件不存在时未调用自定义处理程序.net mvc 3 IIS 7.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆