1

At below, i do simple await call via ajax request on the page and i try to visit other pages or i try to visit page again on another tab but i am not able to visit other pages until Delay action complete.

I tested it on my local IIS Express and on server with full IIS versions. Why my website is not responsive while waiting on await call?

public async Task<ActionResult> Delay()
{
    await Task.Delay(TimeSpan.FromSeconds(30));
    return Content("success");
}
Freshblood
  • 6,285
  • 10
  • 59
  • 96
  • 2
    I'm pretty sure there is some other code responsible for that. This code is fine. – usr Feb 16 '16 at 14:28
  • Have you tried that code in empty project ? I am sure you will experience same thing. – Freshblood Feb 16 '16 at 14:32
  • Possible duplicate of [Task continuation not working after await](http://stackoverflow.com/questions/13992750/task-continuation-not-working-after-await) – Ageonix Feb 16 '16 at 15:04
  • @Ageonix it is not duplicate. – Freshblood Feb 16 '16 at 15:57
  • What answer are you looking for? Your site is unresponsive because of the async task. If you Google this issue, you'll see several articles discussing why this happens and some workarounds. – Ageonix Feb 16 '16 at 16:07
  • @Ageonix My question isn't enough clear ? I already googled it. You can reference some articles. – Freshblood Feb 16 '16 at 17:01
  • @usr Have you tried it on empty project ? – Freshblood Feb 16 '16 at 17:01
  • What MVC version is this? It must natively support Task. Maybe it's calling Result and deadlocking. – usr Feb 16 '16 at 17:03
  • Just try that example in default and latest MVC project. There is no Task.Result calls. I tried this example exactly same on MVC 5.2.3 version. – Freshblood Feb 16 '16 at 17:05
  • 1
    Cannot reproduce. Also, this is supposed to work. ASP.NET is (of course) capable of processing more than one request at a time. – usr Feb 16 '16 at 17:12
  • Maybe your browser is not willing to issue further connections. Use Fiddler to issue requests. – usr Feb 16 '16 at 17:13
  • @usr You are right, i am not able to reproduce this in default project template. So it is clearly not related to browser :(. What else can be ? some web.config setting can cause this ? – Freshblood Feb 16 '16 at 17:28
  • Pause the debugger during the delay and post the stacks that are active at that time. Pause = blocked thread, usually. – usr Feb 16 '16 at 17:39
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/103633/discussion-between-freshblood-and-usr). – Freshblood Feb 16 '16 at 17:58

1 Answers1

0

There is only one possible reason about the issue. ASP.NET doesn't process requests from same user concurrently if session is used. Access to session locks all other requests of the same user and concurrent requests are handled one by one.

Other similar questions

ASP.NET MVC: how to prevent a session lock?

I just discovered why all ASP.Net websites are slow

Community
  • 1
  • 1
Freshblood
  • 6,285
  • 10
  • 59
  • 96