MVC 2.0路线,重定向请求,要求忽略 [英] MVC 2.0 Routes, redirect request, ignore request

查看:128
本文介绍了MVC 2.0路线,重定向请求,要求忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IIS 7.5 MVC 2.0 ASP.NET 4.0

IIS 7.5 MVC 2.0 ASP.NET 4.0

如果我的MVC网站获得任何不存在的文件外部请求,例如SomePage.aspx页面有重定向这样的请求,任何控制器/行动的任何方式。

If my MVC site getting external request for any not existed files, e.g SomePage.aspx is there any ways to redirect such request to any controller/action.

我使用ELMAH,它是引发错误时,这类请求的到来。

I am using elmah and it is throwing errors when such kind of requests coming.

此外,我也加入的global.asax.cs routes.IgnoreRoute(SomePage.aspx页面)忽略这个请求相同,因为我加入忽略的favicon.ico但对于SomaPage.aspx它都不行,反正ELMAH抛出错误。

Also i did add routes.IgnoreRoute("SomePage.aspx") in global.asax.cs to ignore this requests the same as i add to ignore favicon.ico but for SomaPage.aspx it is won't work, elmah throwing errors anyway.

因此​​,有三个问题/解决方案,我会很高兴得到答案:

So there is three questions/solutions i would be happy to get the answers:

1)如何重定向此请求存在控制器/动作

1) How to redirect this request to existed controller/action

2)如何忽略此类请求

2) How to Ignore such kind of requests

3)如何关闭确认文件是否存在在IIS 7.5

3) How to turn off "Verify that file exists" on IIS 7.5

推荐答案

您可以向ELMAH过滤掉某些类型的异常。设置它忽略404错误是一个相当普遍的做法:

You can get Elmah to filter out certain types of exception. Setting it up ignore 404 errors is a fairly common practice:

HTTP://$c$c.google.com/p/ ELMAH /维基/ ErrorFiltering

摘录:

<section name="errorFilter" type="Elmah.ErrorFilterSectionHandler, Elmah" requirePermission="false" />

...

<elmah>
    <errorFilter>
        <test>
            <equal binding="HttpStatusCode" value="404" type="Int32" />
        </test>
    </errorFilter>
</elmah>

这篇关于MVC 2.0路线,重定向请求,要求忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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