当我的操作将用户注销并重定向回自身时,我收到错误“页面未正确重定向”。重定向返回后,再次调用该操作,但 Request.IsAuthenticated 仍然是 true 而不是 false。
我在代码中的每个 FormsAuthentication.SetAuthCookie 调用上都设置了断点,并且没有一个被命中(我想验证没有代码可以重新验证用户)。
public ActionResult MyAction() {
if (Request.IsAuthenticated) {
try {
// Check some stuff put into the session when the user
// is authenticated
} catch {
Session.Abandon();
FormsAuthentication.SignOut();
return Redirect("http://localhost/MyController/MyAction");
}
}
}
完全有可能这是一个 FireFox 问题,因为我使用的是 FireFox 11.0,它似乎在 Chrome 中工作。有谁知道为什么会发生这种情况?
我还没有将其隔离为一个简单的项目。我希望这是我想念的简单的东西。
我还应该提到,我有一个 UrlRewriter 来监视传入的请求,并可能将它们重定向到一个 URL,该 URL 可能具有来自主站点的单独身份验证 cookie。这可能是问题吗?
前任。
// cookiePath: "/"
http://localhost/MyApp/CustomPortal/index/CustomPage
更改为:
// cookiePath: "/CustomPortal"
http://localhost/MyApp/SpecialRequestController/Render?appName=CustomPortal&pagePath=public/CustomPage
当用户通过 MyApp 认证时,cookiePath 为“/”,但如果用户在重写的 URL 下进行认证,则 cookiePath 为“/CustomPortal”。
谢谢您的帮助!