Monday, March 26, 2012

Atlas UpdatePanel and FormsAuthentication Cookie Expiry

Hello all,

i have an ASP.NET 2 website that uses Forms Authentication. When the auth cookie expires, and an attempt is made to refresh a page or post-back, the browser is automatically redirected to the login page, according to settings in the web.config. All is well so far.

I then decided to use Atlas in my pages, specifically the "UpdatePanel" control in order to prevent the whole page being re-served each time when only one control needed to be updated. This also seemed to work fine.

The problem occurs when the Authentication Cookie has expired. Now instead of redirecting to the login page on a post-back, I just get a pop-up msgbox from IE6 saying simpy "Unknown Error". If I refresh the page however using the refresh browser button, i *do* get back to the login page.

I guess the Atlas Update Panel control is somehow minimising the HTML updates in the http reponse (which i guess is the whole point of the Update Panel control).. and blocking the redirect.

I have no clue how to get round this without removing Atlas - but that can't be the solution.. can it? :)

ok i've found my answer in the Atlas forums.. this is a bug in Atlas and although it was apparently supposed to be fixed in the 'next' CTP (July), it wasn't. So i'm not sure when it will be available.
I've not tried, but perhaps in your page load, something like
If Not Me.User.Identity.IsAuthenticatedThen FormsAuthentication.RedirectToLoginPage()End If

yeah, this work-around works.. almost.. if you put this in the Page_Load, it means that the actions of the postback are carried out on the server even though the user is no longer authenticated. Then, when the page_load is executed the user is redirected to the login page because it's only at this point that the authentication is checked.

It would be a bit better if the authentication could be checked in a single place in the Master page_load, but i'm not sure how to check the authentication from here since me.user.identity doesn't work.

No comments:

Post a Comment