views:

700

answers:

2

I want to transfer all unhandled exceptions to an error page in Asp.Net MVC. What is the way to handle the unhandled exceptions in Asp.net MVC? Is there anything like application_error?

+5  A: 

Hi, check out the HandleError attribute. There's a good write up here and here.

Kieron
That's what I'm looking for. Thanks!
yapiskan
+1  A: 

If you are using the standard setup, your controller(s) can do this by overriding one of the methods (proabably OnException, but I don't have it handy to check). If you want all your controllers to share this logic, you can use a base-controller.

Alternatively, you can do this via filters (for example [HandleError]). I don't know if there is a single global place for such logic, though.

Marc Gravell
I have a base controller. I guess it is enough to put this filter to base class. Am I right?
yapiskan
It should be, give it a go...
Kieron