Monday 15 June 2015

jquery - multiple ajax requests very slow mvc -


I have an ASP MVC4 application that loads the dashboard of widgets. Each widget returns an async ajax call on the server and returns a partial.

For some reason these widgets are taking aprox 50 seconds to change the content with partial. Ajax request is instant and the database query is executed on the database basis immediately. Most of the time it works fine but I think it may be related to high usage of the site.

Can anyone recommend me to debug this issue or identify obstacles?

  $ Ajax ({cache: true, type: 'post', async: true, url: '/ observation / getBillingWidget /', success: function (result 3) {if (result3 == '') {$ (' Replacewith ('');} Other {$ ('widget-billing'). Html (result3);}}, error: function () {}}); $ .ajax ({cache: true, type: 'post', async: true, url: '/ observation / GetQueryWidget /', success: function (result 3) {if (result3 == '') {$ ('. Html (result3);}}, Error: function () {}});  

I had the same problem as an application in the same dashboard, and this commentary suggests the problem of session locking. By default, when a controller action is called a session, it is locked until it is done If this happens, then when any call arrives, then It does not have to wait until it is released.

However, with some smart coding, you can avoid the session completely, preferably by storing and reading data in the database. The controllers are only reading session variables (or not using them at all), you can add this attribute to the top of your controller class:

  [the location of the session (System .Web.SessionState.SessionStateBehavior .ReadOnly)]  < / Pre> 

It should solve your locking issues that you can experience with your parallel AJAX calls to your controllers.


No comments:

Post a Comment