c# - Asp.net (MVC) 身份验证 cookie 在重定向时丢失 - 但仅在 Firefox 上
问题描述
在这个上挠头。我设置了一个身份验证 cookie,然后进行了重定向,除了 Firefox,一切正常。我可以看到 cookie 被添加,但在重定向完成后被删除。这在本地主机上的 Edge、Chrome、Safari 和 Firefox 上运行良好,但仅在 Azure 服务器上的 Firefox 上失败。有任何想法吗?
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
0, // ticket version
userid, // authenticated user id
DateTime.Now, // Issue date
DateTime.Now.AddDays(1), // Expiration date
true, // true to persist across browser sessions
"", // can be used to store additional user data
FormsAuthentication.FormsCookiePath); // path
// Encrypt the ticket using the machine key
string cipherText = FormsAuthentication.Encrypt(ticket);
if (null != cipherText)
{
// Add the cookie to the request to save it
cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cipherText);
//cookie.Path = FormsAuthentication.FormsCookiePath;
cookie.Secure = true;
FormsAuthentication.SetAuthCookie(userid, true);
}
Response.Redirect("~/app/dashboard", false);
更新:
所以多挖一点。这部署在 azure 上,实际上在部署槽上工作,但在生产中失败(使用 Firefox)。当我交换插槽(重新映射 IP 地址)时,应用程序不再工作(cookie 不再存在)。
解决方案
推荐阅读
- php - JSON对象循环
- java - 从 Java 到 XML 的 JAXB
- sql - TERADATA:存储在 DBC 中的程序主体在哪里
- sapui5 - fiori 启动板中的稳定 ID
- ios - 未调用 UNNotificationServiceExtension 的 didRecieve
- git - 在共享计算机中管理私钥的最佳方法
- visual-studio-code - 如何阻止某些文件在 vscode 中打开/预览?
- android - 某些列表项发生 NullPointerException
- typescript - 淘汰赛绑定 fontawesome 类
- python - 动态调整小部件内小部件的大小?