I am getting the error "The page isn't redirecting properly" when my action signs the user out and redirects back to itself. After the redirect is returned, the action is called again, but the Request.IsAuthenticated is still true instead of false.
I have put breakpoints on every FormsAuthentication.SetAuthCookie call in my code and none of them are ever hit (I wanted to verify there was no code that would re-authenticate the user).
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");
}
}
}
It is entirely possible this is a FireFox issue as I am using FireFox 11.0 and it seems to work in Chrome. Does anyone know why this would be happening?
I have not isolated this to a simple project yet. I was hoping this is something simple I am missing.
I should also mention that I have a UrlRewriter that monitors the requests coming in and may redirect them to a URL that may have a separate authentication cookie from the main site. Could this be the problem?
Ex.
// cookiePath: "/"
http://localhost/MyApp/CustomPortal/index/CustomPage
Changes to:
// cookiePath: "/CustomPortal"
http://localhost/MyApp/SpecialRequestController/Render?appName=CustomPortal&pagePath=public/CustomPage
When a user is authenticated to MyApp, the cookiePath is "/", but if the user authenticates under the rewritten URL, the cookiePath is "/CustomPortal".
Thanks for the help!