c# - 跨会话保留 ASP.NET Core 3.1 身份外部登录身份验证 cookie
问题描述
我在我的 .NET Core 3.1 项目中使用 ASP.NET Core Identity,并且很难弄清楚如何跨会话保留从外部登录提供程序(例如 Microsoft 或 Google)创建的 cookie。到目前为止,cookie 始终是会话 cookie,无论我尝试过哪个扩展点,都没有改变它。
检查source,可以假设以下方法应该有效,但事实并非如此:
services.AddAuthentication()
.AddMicrosoftAccount(options =>
{
...
options.Events.OnTicketReceived = ctx =>
{
ctx.Properties.IsPersistent = true;
ctx.Properties.ExpiresUtc = DateTime.Now.AddDays(7);
return Task.CompletedTask;
};
});
事件处理程序被成功调用,但.AspNetCore.Identity.Application
cookie 保持不变。我很确定我在这里遗漏了一些相当重要的东西——也就是在错误的地方挖掘:)
解决方案
推荐阅读
- tsql - 在 t/sql 中使用 group by 将多行合并为一个
- python - Python - 按时间间隔合并数据(R data.table 模仿?)
- javascript - Rails - 向上/向下按钮保存到数据库
- pandas - 熊猫结合了滚动和重采样
- pnpm - 自动更新 package-lock.json
- ios - 在 UITableView 中为 UIView 添加自定义类
- google-analytics - 在博客上显示 Google Analytics 信息
- java - 计算函数的运行时间
- php - 从数据库中获取一个值并插入到php中的字符串中
- nginx - WebSocket 握手期间出错:缺少“升级”标头