TheSoftwareJedi
TheSoftwareJedi

Reputation: 35236

Multiple asynchronous jquery calls appear to become processed synchronously by the ASP.NET server

On my page I make 5 or 6 asynchronous calls to some data services to get data for graphs on the page. The responses come back one at a time with a 2-3 second wait between each instead of all as quickly as possible.

I have the jquery code working just fine - according to fiddler and chrome, the calls are all made at the same time but the server appears to processes them one at a time (as evidenced by their returning one by one).

Chrome Network View

It seems that the ASP.NET side is processing them sequentially. On that side the services are standard WebGet operations on a service class which I've tried marking up with:

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]

but that doesn't seem to help. Pausing the debugger shows only one thread in my code at any time. The service code is just EntityContext creation, a linq query, conversion to ajax, return.

Does anyone have any tips on debugging this issue? I'm about to use intellitract to see the actual call times of the methods and such, so try and nail down exactly what it's waiting on.

Upvotes: 0

Views: 310

Answers (1)

LostInComputer
LostInComputer

Reputation: 15410

This is the most likely reason. Your application is:

  1. using ASP.net session
  2. using ASP.net compatibility mode

In ASP.net, requests are processed sequentially if the client has a session and the request handler has read/write access to the session.

If you don't need any ASP.net feature in your WCF, turn off ASP.net compatibility mode in web.config.

<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />

and remove any

[AspNetCompatibilityRequirements(RequirementsMode =
                       AspNetCompatibilityRequirementsMode.Required)]

Edit: Here is a blog discussing the session problem but for ASP.net MVC

Upvotes: 2

Related Questions