Hi Guys,
I'm reading about exception handling in MVC, i have came across 6 methods to do that, now i became more confuse on what to use as currently i have multiple controllers that handle database with EF6. my aim is not to show yellow screen for user and display error page reside in view folder. Do i need to create try and catch block in each controller or use a global filter? could any one shed more lights on this issue ?
thank you

Naveen BishtRank #1,462 · 1.1K reputationPosted Feb 6, 2017, 4:59 AM EST
Sandip G PatilRank #1,083 · 1.8K reputationPosted Feb 6, 2017, 5:15 AM EST
HandleErrorAttribute
public class MyErrorHandling: HandleErrorAttribute { public override void OnException(ExceptionContext filterContext) { Exception ex = filterContext.Exception; filterContext.ExceptionHandled = true; var model = new HandleErrorInfo(filterContext.Exception, "Controller", "Action"); filterContext.Result = new ViewResult() { ViewName = "Error1", ViewData = new ViewDataDictionary(model) }; } }