I'm using ASP.MVC 4. I have a strongly typed layout which is connected to a base view model (every other view model is inheriting from the base view model). I'm trying to handle errors using a standard HandleError filter. It's out of box configured and works if layout isn't strongly typed.
My example exception is following:
public class TestController : Controller
{
public ActionResult Index()
{
throw new Exception("oops");
}
}
When the mechanism tries to plug Error page into strongly typed layout it gets in trouble because there's no model for it.
Does anyone know what is a scenario for using strongly typed layouts with the HandleError filter? Is there any possibility to set model for the layout before the exception is thrown?
EDIT:
Possible solution is turning off standard error handling mechanism and catching exceptions in the Application_Error method in the Global.asax. Example solution you can find here: ASP.MVC HandleError attribute doesn't work
Anyway - if someone have another solution, please post it.