开发者

How make Response.Redirect inside a Asynchronous call method - c#

I have a try-catch inside a method that is called asynchronously. When an error occurs, inside the catch I have a Response.Redirect beca开发者_如何学运维use 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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜