From 37e05cf9644c092bead68f9298b2ff674b318554 Mon Sep 17 00:00:00 2001 From: ksdaylight Date: Wed, 5 Mar 2025 12:48:31 +0800 Subject: [PATCH] fix: The lifetime of AbpCookieAuthenticationHandler needs to be configured as Transient, otherwise the extraction of the cookie named Identity.External will fail --- .../MicroServiceApplicationsSingleModule.Configure.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aspnet-core/services/LY.AIO.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs b/aspnet-core/services/LY.AIO.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs index 5ec0178f6..a1c86c618 100644 --- a/aspnet-core/services/LY.AIO.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs +++ b/aspnet-core/services/LY.AIO.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs @@ -858,7 +858,10 @@ public partial class MicroServiceApplicationsSingleModule options.AutoValidate = false; }); - services.Replace(ServiceLifetime.Scoped); + var originalDescriptor = services.FirstOrDefault(d => d.ServiceType == typeof(CookieAuthenticationHandler)); + var originalLifetime = originalDescriptor?.Lifetime ?? ServiceLifetime.Transient; // 默认用 Transient + + services.Replace(originalLifetime); services.AddAuthentication() .AddAbpJwtBearer(options =>