From ac134308edf3767ebd243c006f324051402b00ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Tue, 28 Jun 2022 20:21:51 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E8=BF=94=E5=9B=9E=E4=B8=AD=E6=96=87=E4=B9=B1?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Middleware/GlobalExceptionMiddleware.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs b/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs index db875f8..cdc619a 100644 --- a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs +++ b/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs @@ -106,16 +106,18 @@ namespace ZR.Admin.WebApi.Middleware sysOperLog.jsonResult = logAttribute.IsSaveResponseData ? sysOperLog.jsonResult : ""; } } - LogEventInfo ei = new(logLevel, "GlobalExceptionMiddleware", error); - - ei.Exception = ex; - ei.Message = error; + LogEventInfo ei = new(logLevel, "GlobalExceptionMiddleware", error) + { + Exception = ex, + Message = error + }; ei.Properties["status"] = 1;//走正常返回都是通过走GlobalExceptionFilter不通过 ei.Properties["jsonResult"] = responseResult; ei.Properties["requestParam"] = sysOperLog.operParam; ei.Properties["user"] = HttpContextExtension.GetName(context); Logger.Log(ei); + context.Response.ContentType = "text/json;charset=utf-8"; await context.Response.WriteAsync(responseResult, System.Text.Encoding.UTF8); SysOperLogService.InsertOperlog(sysOperLog);