12

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?

2 Answers 2

9

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

Sign up to request clarification or add additional context in comments.

Comments

2

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.

1 Comment

I have a base controller. I guess it is enough to put this filter to base class. Am I right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.