开发者

What is the purpose of RegisterGlobalFilters?

In MVC3, I have CustomErrors enabled this way:

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

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

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

What i开发者_如何学Pythons the real purpose of this call to RegisterGlobalFilters?


This is working because you still have a defaultRedirect specified.

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);

So in short - you do need to register your global filters if you want this to work and have the error details properly pushed through, otherwise I don't think your HandleErrorInfo values will be accessible in /Error/Generic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜