EDIT: This was apparently an issue with testing in the browser, not with the code. Sessions in Core are disabled by default as they should be.
Original question:
I'm working on a web API which needs to handle multiple requests concurrently, even from the same client. It is an ASP.NET Core MVC (1.1.2) app currently targeting the full framework (4.5.2), mostly for compatibility with other libraries.
When I first tested my concurrency, I was surprised that the requests were not concurrent at all. I googled around and found out that ASP.NET does not handle requests within a session concurrently, but instead queues them. A quick test shows that sessions are likely to be the culprit:
[HttpGet("sleep")]
public string Sleep()
{
Thread.Sleep(5000);
return $"Done at {DateTime.Now:u}";
}
When I rapidly request this from multiple tabs in the same browser, it takes 5 seconds between each tab. This is not the case when I use multiple browsers, it responds multiple times within a 5 second window.
When searching for a solution I kept stumbling upon ways to disable session state in ASP.NET, but nothing for Core.
As far as sessions are concerned, I am using the default API project template and I have done nothing to specifically enable/setup session state.
Is there a way to get rid of session state in ASP.NET Core? Or is there a better solution to enable concurrent requests?