开发者

ASP.NET - Handle redirect after async post back

开发者 https://www.devze.com 2023-03-15 11:53 出处:网络
I have an ASP.NET web application that uses Upda开发者_开发百科te Panels. The web application is integrated in a SiteMinder SSO environment.

I have an ASP.NET web application that uses Upda开发者_开发百科te Panels. The web application is integrated in a SiteMinder SSO environment.

The problem occurs when Siteminder thinks it is time to re-authenticate the user. When the user performs an action that results in an async postback, Siteminder catches this request and sends back a redirect response to its login page.

My ASP.NET page does not expect this and throws an PageRequestManagerParserErrorException.

My guess is that I have to catch this redirect response in client code (using a PageRequestManager event?) and handle the redirect correctly.

But how?


I have the same problem. I found one solution here: http://forums.asp.net/t/1470176.aspx/1

I ended up with the following javascript on each page:

function pageLoad() {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

function EndRequestHandler(sender, args) {
    if (args.get_error() != undefined) {
        if (args.get_response().get_responseData().indexOf("<HTML><HEAD><TITLE>") == 0) {
            args.set_errorHandled(true);
            __doPostBack("", "");
        }
        else {
            // not my error so let the default behavior happen
        }
    }
}

It stops the page from beaking completely but it does do a full page refresh instead of an async postback once SSO has timed out on the client.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号