views:

43

answers:

1

I have a try-catch inside a method that is called asynchronously. When an error occurs, inside the catch I have a Response.Redirect because I need to redirect to the login page.

This is my issue.

But my problem doesn't involve things that expire, so the idea of a timer isn't the best way to resolve it.

+1  A: 

The method you are calling in your callback is outside of the context of a full page request. What you need to do is return in the response a value that prompts the browser to perform a redirect from the client side. This could be as simple as a javascript window.location call to login.aspx. The callback handler on the client side will need logic to recognise this and to eval the javascript (which will essentially execute it).

An alternative would be to return an error header to the browser and in the error handler set up in the ajax call, perform the window.location ='login.aspx'; call.

Daniel Dyson
Daniel, you're right. Tks
Mr. Ott
No problem. Could you mark this as the right answer please?
Daniel Dyson