예제 #1
0
 public CustomExceptionMiddleWare(RequestDelegate next, CustomExceptionMiddleWareOption option)
 {
     _next   = next;
     _option = option;
     exceptionStatusCodeDic = new Dictionary <int, string>
     {
         { 401, "未授权的请求" },
         { 404, "找不到该页面" },
         { 403, "访问被拒绝" },
         { 500, "服务器发生意外的错误" }
         //其余状态自行扩展
     };
 }
 public static IApplicationBuilder UseCustomException(this IApplicationBuilder app, CustomExceptionMiddleWareOption option)
 {
     return(app.UseMiddleware <CustomExceptionMiddleWare>(option));
 }