Hello!
I have an atlas web application that is also set up with forms authentication. The MembershipProvider "userIsOnlineTimeWindow" is set to "20". When i log the user in and leave the application on an AJAX enabled page (with updatepanels etc..) and then return to the application 23 minutes later - and click a button that triggers an updatepanel - i get a javascript error! Is there any way of dealing with this? Ideally i would just like the user to be redirected to the login page.
Please give me loads of details! :)
Thanks, Callam
You could set up a timer on the page to keep the authentication ticket live...
+++ Rick --
Hi Rick!
Thanks for that suggestion, but is that really what everyone who uses ATLAS in this way has to do? Are there no existing mechanisms? If i were to implement a timer - how would i go about it?
:) - Callam
The only way I don't know. But there's no built in mechanism for UpdatePanel at the moment to trigger it from the client. Remember UpdatePanel isn't all of ATLAS - there are other ways to make callbacks that give you much more control, but you have to do a little more work and write client script.
What I'm suggesting lets you still use UpdatePanel but gives you the behavior you want through a hack with a few lines of JavaScript code. Something like this:
function StartCallbacks()
{
$("btnHiddenFireFirstRequest").click();
window.setTimeout("$('btnHiddenSecondRequest').click()",100);
}
Now you have two server buttons with that don't post back on the form with the names above. You then set each of the update panel triggers to the appropriate button's click event and off you go.
Actually you may not need two buttons - probably only one since the initiating event can be something that would trigger anyway.
+++ Rick --
hello.
well, currently its's your best option. your other option is to build the authorization module so that you get the correct response when performing a partial postback and the session ticked has expired.
Hi Callam,
I use this solution to the same problem. In the Page_Load I put the following to detect a lost session while doing a partial postback:
// redirect if session is lost when doing a asynchroneous update (atlas)
if (((Microsoft.Web.UI.ScriptManager)Master.FindControl("asm")).IsInPartialRenderingMode)
{
if (null == Session["userid"])
{
Response.Redirect("~/login.aspx");
}
}
It works for me.
/lasse
Hi!
I'm not able to test that just yet - but is there allways a session variable called "userid" for formsAuthentication?
Thanks for your response! - Callam
Callam, I would suggest that you handle the PageRequestManager endRequest on the client, inspect the error and then based on that you can actually redirect from the client if the error was related to cookie expiration. simple code to handle endRequest error. You need to be onBeta1.0 to be able to run this code
<script language="javascript" type="text/javascript">
function endRequestEventHandler(sender, arg) {
arg.set_errorHandled(true);
if (e.get_error().message == '...')
...
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestEventHandler);
</script>
Thanks,
Kashif
hello.
hum..is this really necessary? i mean, i'm convinced that the team has solved this issue with this release, ie, it properly detects the expiration of the cookie and automatically redirects the user to the login page.
Yes, the redirection handling happens automatically in Beta - the code relates more to if the user was getting an error during an async post-back and wanted to handle it on the client.
hello again.
hum...ok. i thought that the initial question was on how to prevent the error that used to happen in previous ctp when a timeout occurred.
where can i find the beta version that you guys are talking about? about 3 weeks ago i downloaded the latest version and used it when writing an authentication application. After leaving the authentication to time out, the first click of a postback ling resulted in nothing - and the second click redirected it to the login page
Can someone explain that?
:) thanks - this is brilliant help ;)
- Callam
hello.
well, i think it was released today (or yeasterday). it has lots of improvements and this bug has been solved on this latest release.
I linked to the Beta in the earlier post - but here goesagain
Ah great thanks a lot for that.
If i already have an application running on the july CTP, is it easy to upgrade it to the beta version? Thanks, Callam
No comments:
Post a Comment