ExceptionFilter ExceptionFilter 1.自定义一个CustomExceptionFilterAttribute ,实现IExceptionFilter接口, 2.实现方法,先判断,异常是否被处理过,如果没有被处理过,就处理; 3.分情况处理:1.如果是ajax请求,就返回JosnResult,如果不是Ajax请求,就返回错误页面 4.全局注册,在Starup中的ConfigureServices注册 5.测试 ExceptionFilter 1.自定义一个CustomExceptionFilterAttribute ,实现IExceptionFilter接口, 2.实现方法,先判断,异常是否被处理过,如果没有被处理过,就处理; 3.分情况处理:1.如果是ajax请求,就返回JosnResult,如果不是Ajax请求,就返回错误页面 public class CustomExceptionFilterAttribute : Attribute, IExceptionFilter