0

I see there is a nice [HandeError] attribute which could be applied on controller class or method. What is my options if I would like to catch and handle exceptions which ocurred during rendering?

1 Answer 1

2

i prefer to use the Global.asax:

protected void Application_Error(object sender, EventArgs e)
{
    var exception = Server.GetLastError();
    // do something with the exception
}

Edit re comment

ASP MVC is still ASP.NET, so yes this still works fine.

If some some reason you want to handle Rendering errors differently, you could override the default WebFormsViewEngine and wrap a try catch around the view generation methods, thats a bit overkill though.

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

1 Comment

Yes, this is nice method which worked fine in asp.net. I was sure it is not supported by mvc... I will check and accept answer then

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.