我在一个asp.net core MVC项目的登录表单中实现了记住我选项,所以我遇到了在cookie中保存令牌的主题,并且cookie必须存在于方案中。据我了解,有一个默认方案,默认命名为“Cookies”。
我目前对
ConfigureApplicationCookie(...)
方法感到困惑,因为我不知道我们正在配置的 cookie 与哪个方案相关。
您可以检查
ConfigureApplicationCookie
的源代码,这是身份库代码:
源码如下,用于配置
Identity.Application
方案。不是您添加的 cookie 方案。
代码:
/// <summary>
/// Configures the application cookie.
/// </summary>
/// <param name="services">The services available in the application.</param>
/// <param name="configure">An action to configure the <see cref="CookieAuthenticationOptions"/>.</param>
/// <returns>The services.</returns>
public static IServiceCollection ConfigureApplicationCookie(this IServiceCollection services, Action<CookieAuthenticationOptions> configure)
=> services.Configure(IdentityConstants.ApplicationScheme, configure);
IdentityConstants.ApplicationScheme
的结果如下: