Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 is the real purpose of this call to RegisterGlobalFilters?

like image 800
user385411 Avatar asked Nov 25 '25 21:11

user385411


1 Answers

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.

like image 56
Adam Tuliper Avatar answered Nov 28 '25 09:11

Adam Tuliper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!