。net core 3中的_signInManager.PasswordSignInAsync方法中出现错误

问题描述 投票:1回答:1

我正在使用CookieAuthenticationDefaults.AuthenticationScheme

当我尝试使用signInManager.PasswordSignInAsync方法时,出现此错误===>

cookie.Expiration被忽略,请改用ExpireTimeSpan。

如何解决此错误?

asp.net-core-mvc asp.net-core-3.1 asp.net-core-identity cookie-authentication
1个回答
0
投票

this doc中,您可以找到在ASP.NET Core应用程序中实现基于cookie的身份验证,我们可以在下面选择两个选项之一

  1. Use cookies with Identity

  2. Use cookies without Identity

首先,您似乎在一个应用程序中混合/配置了两个选项。如果指定了options.Cookie.Expiration,则将导致此问题。

// code of configure Identity service

services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(options =>
    {
        options.Cookie.Expiration = TimeSpan.FromDays(10);
        //....
    });

//...

测试结果

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.