瀏覽代碼

修复500报404

DuGuYang 1 年之前
父節點
當前提交
93654528d1
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      Filter/GlobalExceptionsFilter.cs

+ 3 - 0
Filter/GlobalExceptionsFilter.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Net;
 using Library;
 using Microsoft.AspNetCore.Mvc.Filters;
 
@@ -11,6 +12,8 @@ namespace MySystem
             string Message = context.Exception.Message;
             string StackTrace = context.Exception.StackTrace;
             function.WriteLog(DateTime.Now.ToString() + "\r\n" + Message + "\r\n" + StackTrace, "Global全局异常处理日志");
+            context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
+            context.ExceptionHandled = true;
         }
     }
 }