New FormsAuthentication.SignOut behavior in ASP.NET 2.0
Calling FormsAuthentication.SignOut() removes the FormsAuthentication cookies in ASP.NET 1.1. Sometimes folks call it from their Login page, like this:
This says, "If this is a fresh load of this page, clear out the authentication cookies."
If this seems like a reasonable thing, that's because it is. However, if you run an ASP.NET 1.1 site under ASP.NET 2.0 without recompiling, as a number of dasBlog users do, you may get some odd behavior.
You'll visit the Login.aspx page and redirect to the Login.aspx page forever in a loop...it will make your URL look like this:
Why? Because ASP.NET 2.0 add this code inside SignOut():
if (FormsAuthentication.CookieMode != HttpCookieMode.UseCookies)
That's pretty interesting. If you call SignOut() it redirects you to the Login page, but only if your CookieMode isn't set to UseCookies. This is because ASP.NET 2.0 added support for cookieless FormsAuthentication. They store the auth information in the URL, and they redirect you because they want to clear the authentication info. Makes sense.
What doesn't make sense is why HttpCookieMode doesn't default to UseCookies. It defaults to Cookieless. Which is lovely under ASP.NET 2.0, but not under 1.1. It stays that way and confuses the system.
So, if you see this kind of infinite redirect with FormsAuthentication while running ASP.NET 1.1 applications under ASP.NET 2.0, you can add cookieless="UseCookies" to your <forms> element in web.config:
<forms cookieless="UseCookies" name=".DASBLOGAUTH" protection="All" timeout="60" path="/"/>
And then I went to sleep.
Now playing: Counting Crows - Angels of the Silences