修改验签错误应用程序出错的问题

This commit is contained in:
xxred
2018-11-06 17:33:23 +08:00
parent df3597792d
commit a391f3d358
+7 -1
View File
@@ -6,6 +6,7 @@ using COMCMS.Common;
using COMCMS.Web.Common;
using COMCMS.Web.Controllers.api;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
@@ -39,7 +40,12 @@ namespace COMCMS.Web.Filter
if (notVali != null)
{
await context.HttpContext.Response.WriteAsync(notVali.ToJson());
// 过滤器不要抛出错误,也不要向响应流写东西,应该直接赋值Result进行短路
context.Result = new ContentResult()
{
Content = notVali.ToJson(),
ContentType = "application/json"
};
}
}