I have a problem when running an MVC4 website from my visual studio debugger, if there are too many pages open, the ajax request takes a very long time to begin sending. The very strange thing is that if I close one of the pages, the request will start immediately.
More details... Framework: MVC 4 IDE: Visual Studio 2010 Browser: IE 9/Chrome
Controller:
[Authorize]
[SessionState(SessionStateBehavior.Disabled)]
public class AnalyticsController
: Controller
{
public ActionResult SaveWorkspace( Workspace model)
{
var returnVal = _save(model);
return Json(new { actionResult = returnVal, messages = new string[] {} } );
}
}
I have tried this with both an AsyncController and inheriting from Controller with the same results.
Client:
$.ajax({
url: '/Analytics/SaveWorkspace',
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(workspace),
success: function (result) {
alert("Function Executed");
}
});
Above is the ajax call I use. What I do is click various links on my web page which will open new windows. For my test, I opened the initial browser from my debugger and from my main page I spawned 5 other browsers. The call above executes immediately from the window started by my debugger but when I view the request from the network capture it will sit saying "Pending" until it eventually timed-out.
Now the interesting part is that if I close any one of those windows I spawned, the request will change from pending and go to my controller and return as expected. With a little more playing around, if I try it again (not opening additional browsers) it will always get sent to the server immediately, but if I open that 5th browser, then it becomes slow again. I did various tests to make sure nothing was wrong with specific windows, it seems to be that magic number of 5 browsers that causes my request to not be sent.
Here is a screenshot of my successful request when I close the 5th browser window.
Here is a capture of my request headers
Here is a capture of my response headers
Here is a capture of my timings
The main thing I can't really understand is why there is a 46 second wait period and then two start periods. It seems the first start period was the long one, and the second start happened when I closed my 5th browser window.
I tried to provide as much detail as possible along with data to help diagnose what is going on. If there is anything else I can do to paint a better picture, feel free to post a comment. Any suggestions will be more than welcome.
Thank you all!