Home > Software engineering >  Make .NET Core controller action non-blocking
Make .NET Core controller action non-blocking

Time:10-02

From what I understand, asynchronous methods allow the handling of http requests so that those requests are handled without blocking further requests. I would expect IIS to be able to handle multiple requests to this method at the same time. what actually happens when I test this is that these requests are processed one at a time. What am I missing?

    public async Task<IActionResult> Index()
    {

        await Task.Run(() =>
        {
            Thread.Sleep(10000);
        }); 

        return View();
    }

EDIT: I tried to send the request via Postman instead of Chrome and it beheavies as expected. Request are processed simultaneously. At this point I'm wondering why Chrome is waiting for the previous request to be processed before sending another one. Here below the screenshot from the Chrome network window.

enter image description here

CodePudding user response:

This behavior is due to Chrome locking the cache and waiting to see the result of one request before requesting the same resource again. Chrome stalls when making multiple requests to same resource?.

  • Related