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