views:

18

answers:

1

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?

+2  A: 

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.

Andrew Bullock
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
Sergey Osypchuk