什么是RegisterGlobalFilters的目的是什么? [英] What is the purpose of RegisterGlobalFilters?

查看:873
本文介绍了什么是RegisterGlobalFilters的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC3,我的customErrors启用此方式:

In MVC3, I have CustomErrors enabled this way:

<customErrors mode="On" defaultRedirect="/Error/Generic"/>

和它的工作原理无论添加或不 HandleErrorAttribute GlobalFilterCollection 过滤器。

And It works whatever I add or not the HandleErrorAttribute to the GlobalFilterCollection filters.

无效的Application_Start(),如果我注释掉该行它不会改变任何东西
RegisterGlobalFilters(GlobalFilters.Filters);

In void Application_Start(), it does not change anything if I comment out this line RegisterGlobalFilters (GlobalFilters.Filters);

这是什么调用的真正目的 RegisterGlobalFilters

What is the real purpose of this call to RegisterGlobalFilters?

推荐答案

这是工作,因为你还有指定的defaultRedirect。

This is working because you still have a defaultRedirect specified.

如果你删除它,您的自定义错误不会,如果你有工作,的customErrors =ON并指定了`的HandleError没有或,如果你注释掉:

If you remove it, your custom errors will not work if you have customErrors="On" and do not have either `HandleError specified OR if you comment out:

RegisterGlobalFilters(GlobalFilters.Filters);

因此​​,在短期的 - 你需要的,如果你想要这个工作,有错误的详细信息,通过适当推到注册全局过滤器,否则我不认为你的 HandleErrorInfo 值将在访问 /错误/通用

这篇关于什么是RegisterGlobalFilters的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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