protected override void OnException(ExceptionContext filterContext) { IEx iex = ExceptionFactory.CreateException(ExceptionEnum.DatabaseException); Exception ex = filterContext.Exception; //Log Exception ex Session["Exception"] = iex.Msg(ex); //return; // Redirect on error: //filterContext.ExceptionHandled = false; //return; //filterContext.Result = new RedirectToRouteResult( // new RouteValueDictionary( // new // { // controller = "Error", // action = "General" // }) // ); //filterContext.Result = new ViewResult //{ // ViewName = "~/Views/Shared/Error.cshtml" //}; //// OR set the result without redirection: //filterContext.Result = new ViewResult //{ // ViewName = "~/Views/Error/Index.cshtml" //}; }
protected override void OnException(ExceptionContext filterContext) { IEx iex = ExceptionFactory.CreateException(ExceptionEnum.DatabaseException); Exception ex = filterContext.Exception; //Log Exception ex Session["Exception"] = iex.Msg(ex); }
public override void OnException(HttpActionExecutedContext actionExecutedContext) { IEx iex = ExceptionFactory.CreateException(ExceptionEnum.DatabaseException); var response = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError) { Content = new StringContent(iex.Msg(actionExecutedContext.Exception)) }; //log error into PSA DB PSAServiceObj.AddErrorLog(CreateErrorLogObject(actionExecutedContext)); actionExecutedContext.Response = response; }