Wednesday, March 21, 2012

ASP .NET Ajax, Windows Authentication and 401.1

Hi all!

I have a website on IIS with Windows Authentication only. Website uses UpdatePanel.

Scenario:

- some user is authenticated on site and browses it

- at some moment his password in Active Directory is changed

- after that user clicks somewhere on site (UpdatePanel tries to update its content)

- user sees Windows Authentication form, enters his login and incorrect password and then press OK three times

- he receives dialog with error message "Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occured while processing the request on the server. The status code returned from the server was: 401".

How to handle this error on the client? How can I redirect user to error page?

For now I found some simple solution. I just suppress error and refresh page.

<asp:ScriptManager

ID="ScriptManager1"

runat="server">

</asp:ScriptManager>

<scripttype="text/javascript"language="javascript">

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args)

{

if (args.get_error() != undefined)

{

args.set_errorHandled(true);location.reload(true);

}

}

</script>


Thanks a lot.

It is also a solution for all PageRequestManagerServerErrorException- Problems.

(12031, 12030, ...)

No comments:

Post a Comment