Asp.net 身份。记住我,不要工作

Asp.net identity. Remember me, don't work

我创建了一个新的 ASP.NET Core 3.1 MVC 项目。身份验证更改:在应用程序中存储用户帐户。

添加新的脚手架项目 -> 身份 -> 选择 Account\login 并注册

设置:

ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(options =>
          options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
 
    services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
                .AddEntityFrameworkStores<ApplicationDbContext>();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseAuthentication();
    app.UseAuthorization();
}

下一个我运行Update-database:

User registration is successful.

但是如果我使用“记住我”标志登录。然后下次我去登录页面。字段名称和密码为空。如何实现这些字段的自动填充?

“记住我”选项确定身份验证 cookie 是否在当前浏览器会话之后仍然存在。它不会 - 也不应该 - 尝试在任何地方保留您的凭据。

所有现代浏览器都有内置的密码管理器,并且有大量可用于第三方密码管理器的扩展。让浏览器负责记住登录详细信息。任何其他事情都将不可避免地变得非常不安全。

Troy Hunt: How to build (and how not to build) a secure “remember me” feature