1

I am wondering today.

In my project ajax not making asynchronous call. request is sending one after another.

while processing one request, rest other all requests putting in pending.

you can see in below image enter image description here

this happening from last night.

Rakesh
  • 411
  • 2
  • 5
  • 15
  • Could you provide us the code which sends the ajax requests? – ahendwh2 Feb 02 '18 at 07:53
  • Hope the link https://stackoverflow.com/questions/6685249/jquery-performing-synchronous-ajax-requests help you out – karthik kasubha Feb 02 '18 at 07:57
  • function DelVideos(VideoID) { var param = { "VideoID": VideoID }; param = JSON.stringify(param); $.ajax({ type: "Post", url: "/KnowledgeAreas/DelVideos", contentType: "application/json; charset=utf-8", data: param, success: function (data) { $('#DelVideoModal').find('button.close').click(); GetVideos(); }, error: function (response) { alert(response); } }); }; – Rakesh Feb 02 '18 at 07:58
  • it normal ajax call only it was working up to last night. i don't know what happen in my project . – Rakesh Feb 02 '18 at 07:59
  • requests are sending one after another – Rakesh Feb 02 '18 at 08:00
  • In your code you can see that `GetVideos()` gets called after the ajax call "DelVideos" is completed so it acts like synchronous requests. – ahendwh2 Feb 02 '18 at 08:06
  • How get insVideos, AddVideos and DelVideos called? After users clicks something or automatically through your code or something else? – ahendwh2 Feb 02 '18 at 08:07
  • after user click – Rakesh Feb 02 '18 at 09:18

1 Answers1

2

It is not relevant how is applying Ajax calls. It is mostly relevant with ASP.NET is managing session. Here is the official documentation.

Concurrent Requests and Session State

Access to ASP.NET session state is exclusive per session, which means that if two different users make concurrent requests, access to each separate session is granted concurrently. However, if two concurrent requests are made for the same session (by using the same SessionID value), the first request gets exclusive access to the session information. The second request executes only after the first request is finished.

As you see, if two concurrent requests are made for the same session (so in your case it is) the second one applying after the first request is responsed.

EDIT

If you don't want that behaviour, you can decorate your controller with SessionStateAttribute and disable to access the session.

[SessionState(SessionStateBehavior.Disabled)]

If you want to only read access to the session, you can add the attribute like this.

[SessionState(SessionStateBehavior.ReadOnly)]
lucky
  • 12,734
  • 4
  • 24
  • 46