Browse Source

提交异常处理的Bug

CrazyIter 5 năm trước cách đây
mục cha
commit
f11564af15

+ 4 - 1
TEAMModelOS.SDK/Context/Filters/HttpGlobalExceptionInvoke.cs

@@ -104,7 +104,10 @@ namespace TEAMModelOS.SDK.Context.Filter
         {
             var data = new ErrorResponse<string>(bizCode, msg, devmsg);
             context.Response.ContentType = Constants.CONTENT_TYPE_JSON;
-            await context.Response.WriteAsync(JsonNetHelper.ToJson(data));
+            if (context.Response.HasStarted) {
+                await context.Response.WriteAsync(JsonNetHelper.ToJson(data));
+            }
+           
         }
         /// <summary>
         /// 异常信息封装

+ 0 - 15
TEAMModelOS/ServiceProviderFactory.cs

@@ -1,15 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace TEAMModelOS
-{
-    public static class ServiceProviderFactory
-    {
-         static    ServiceProviderFactory() { 
-        
-        }
-    }
-}

+ 1 - 3
TEAMModelOS/Startup.cs

@@ -125,6 +125,7 @@ namespace TEAMModelOS
             CSRedis.CSRedisClient.Serialize = obj =>System.Text.Json.JsonSerializer.Serialize(obj);
             CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
             RedisHelper.Initialization(csredis);
+           // RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
             //services.AddSingleton<PowerPointService, PowerPointService>();
 
 
@@ -137,8 +138,6 @@ namespace TEAMModelOS
                .AddClasses(classes => classes.AssignableTo<IChangeService>()).UsingRegistrationStrategy(RegistrationStrategy.Skip)
                    .AsImplementedInterfaces()
                   .WithSingletonLifetime());
-
-
             _services = services;
         }
 
@@ -149,7 +148,6 @@ namespace TEAMModelOS
             {
                 app.UseDeveloperExceptionPage();
             }
-
             Dictionary<string ,CosmosModelInfo> dict=  cosmosDBV3Repository.InitializeDatabase().Result;
             changeFeedInvoke.MonitorChangeFeed(dict, _services);
             app.UseMiddleware<HttpGlobalExceptionInvoke>();