Beispiel #1
0
        public override void OnException(ExceptionContext filterContext)
        {
            var writeLog = true;

            if (filterContext.Exception.GetType().ToString() == typeof(BWException).ToString())
            {
                writeLog = ((BWException)filterContext.Exception).WriteLog;
            }

            var customErrors = ((CustomErrorsSection)WebConfigurationManager.GetSection("system.web/customErrors"));

            var exResult = new ExceptionResult
                           (
                filterContext.Exception.Message,
                isWriteLog: writeLog,
                controller: filterContext.Controller.ToString(),
                stackTrace: filterContext.Exception.StackTrace
                           );

            if (customErrors.Mode == CustomErrorsMode.On)
            {
                exResult.ExecuteResult(filterContext);
                filterContext.RequestContext.HttpContext.Response.End();
            }
            else
            {
                base.OnException(filterContext);
            }
        }