에러 처리 HandleErrorAttribute

ExceptionInfo info = new ExceptionInfo();            

info.Success = false;            

info.Message = filterContext.Exception.Message.ToString();            

info.Data = null;

            //filterContext.HttpContext.Request.IsAjaxRequest()

            filterContext.Result = new JsonResult() { Data =info};            

filterContext.ExceptionHandled = true;            

filterContext.HttpContext.Response.Clear();           

// filterContext.HttpContext.Response.StatusCode = 500;

            filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;

 

FilterConfig에 등록 할것 

 

 filters.Add(new HandleErrorAttribute());

posted @ 2017-03-15 16:31  汉城  阅读(101)  评论(0编辑  收藏  举报