Monday, September 28, 2015

ASP.NET Concurrent Ajax Requests and slow performance

While working on a client project I came across an interesting issue. That is when concurrent Ajax requests (originating from Jquery ajax) came in the asp.net web service (A set of aspx web methods in this case) were performing ridiculously slow. The methods it self were executing pretty fast. It turned out that when you have "[WebMethod(EnableSession = true)]" the requests are processed sequentially with in the same session.

The fix is to make the session read only, that is if your web methods are not modifying the session.

If any other page methods are modifying the session then the best approach is to move your web methods to a different aspx file and make the session read only for that page. Below given is the page directive for doing that,

<% @Page EnableSessionState="ReadOnly" %>

Hope this helps.

0 comments:

Post a Comment