long running ajax request preventing page reload
I'm using jquery to make an ajax request to a controller method that can potentially take a while to return. The problem I'm having is that I can't reload the page until the ajax request finishes.. it just hangs until the controller method finishes and then does the page reload.
This is my ajax request.
$.ajax({ async:true, type: "POST", url: url, data: senddata, dataType: "xml", success: GetLayerFeaturesCallback });
I'm using an AsyncController and waiting 10 seconds to return.
public void GetFeaturesAsync(int layerId, BoundingBox bbox, int maxFeatures = 50)
{
AsyncManager.OutstandingOperations.Increment();
Task task = Task.Factory.StartNew(() => {
System.Threading.Thread.Sleep(10000);
});
task.ContinueWith(t => {
AsyncManager.Parameters["element"] = new XElement("TEST");
AsyncManager.Outstan开发者_开发技巧dingOperations.Decrement();
});
}
public XmlActionResult GetFeaturesCompleted(XElement element)
{
return new XmlActionResult(element);
}
Why can't I reload the page until that method finishes?
Might be a deadlock in your application or the number of threads or connections(per ip) allowed to process is limited by the webserver.
Can you open ANY other page from another browser or from another computer while the long request is processing?
edit sessions in asp.net also causes lock-ups. Only one request at a time may access a session unless you have marked the pages' session as read-only.
精彩评论