Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top