diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs index 181aaf3ec8..d2c328f2ae 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/Claims/AbpDynamicClaimsMiddleware.cs @@ -24,19 +24,15 @@ public class AbpDynamicClaimsMiddleware : AbpMiddlewareBase, ITransientDependenc if (context.User.Identity?.IsAuthenticated == false) { + var authenticationSchemeProvider = context.RequestServices.GetRequiredService(); if (!authenticationType.IsNullOrWhiteSpace()) { - var authenticationSchemeProvider = context.RequestServices.GetRequiredService(); - var scheme = await authenticationSchemeProvider.GetSchemeAsync(authenticationType); - if (scheme != null) + var authenticationScheme = await authenticationSchemeProvider.GetSchemeAsync(authenticationType); + if (authenticationScheme != null && typeof(IAuthenticationSignOutHandler).IsAssignableFrom(authenticationScheme.HandlerType)) { - await context.SignOutAsync(scheme.Name); + await context.SignOutAsync(authenticationScheme.Name); } } - else - { - await context.SignOutAsync(); - } } } }