开发者

Abort Synchronous Postback in ASP.net Webforms

I have a webforms app that is hosting a silverlight project. The silverlight project makes a call to JavaScript on its host page. This JavaScript does a few bits and then clicks a button on th开发者_开发知识库e host page. This causes a postback, the response to which is a file, resulting in the user seeing the browsers file download window.

The creation of the file can take quite a bit of time and what I've discovered is that if the user requests that the file is generated, gets bored of waiting and presses refresh in the browser, the silverlight app will not load until the original postback (caused by the JavaScript call) has completed.

What I'd like to do provide a mechanism to abandon the file generation request, I don't care if it keeps going on the server, and currently I'm just interested in giving the user back their application.

How might I go about canceling a synchronous postback from JavaScript?


I don't think there is much javascript can do to cancel something happening server side.

How about making the request asynchronous or using javascript to redirect the page?

I just saw a similar post Stop a postback in javascript and they recommend window.stop(), but I don't think it works on IE and documentation also says it´s just the equivalent to the stop button in the browser, which does n't add a lot of value to the user.

Making the request asynchronous seems like a good plan.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜