AJAX and Forms Authenication Timeout

A

Angel666

We are using forms authenication with AJAX update control panels. We
get various results but no redirect when the user has timed out and is
no longer authenicated and does a asyncpostback. We have tried
onasyncpostbackerror method but it is not even hitting the code
behind.
Because the server does try to redirect to login page we get the
parser error(below) as it is trying to parse the login page in the
background.


Sys.WebForms.PageRequestManagerParserErrorException: The message
received
from the server could not be parsed. Common causes for this error are
when
the response is modified by calls to Response.Write(), response
filters,
HttpModules, or server trace is enabled.


Details: Error parsing near ' |<html>


<head>

Is there any solution for authenication time out with the Update panel
usage that can do a redirect on asynchpostbacks??
Thank you
Joe
 
B

bruce barker

using a cutom OnAuthenicate, you could detect it was an async postback
(check for "X-MicrosoftAjax" header), and respond with an ajax compatiable
error response, instead of redirecting to the login page.

-- bruce (sqlwork.com)
 
A

Angel666

Let me clarify. We are using standard .Net forms authenication. Users
login fine but it is once we are in the application.

A user waits pass the timeout then interacts with a page inside the
application that has an update panel
and we get the famous PageMgrParser problem because what is being sent
via the response is the login page as it should.
Problem is response doesnt know how to handle this so blows up. We
tried onAsychPostBackError but the code behind doesnt even get hit.

Any ideas?
 
Joined
Oct 17, 2008
Messages
2
Reaction score
0
client side handler

Add a client side event handler for EndRequest. Place this code after your ScriptManager tag and perform whatever redirection you want....

/* get this page's PageRequestManager and add a handler to get the response from the server */
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
if (args.get_error() != undefined)
{
var errorMessage = args.get_error().message;
var statusCode = args.get_response().get_statusCode();
if (statusCode == '0' || statusCode == '12030' || statusCode == '12031')
{ /* timeout or server N/A - second two are MS proprietary */
window.location.pathname = '/Login.aspx?ReturnUrl=' + window.location.pathname;
}
else
{
alert(errorMessage);
}
args.set_errorHandled(true);
}
}
/* notify script manager that script has been loaded (add this only if you have it in an external file) */
if (typeof(Sys) != 'undefined') Sys.Application.notifyScriptLoaded();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top