Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Question: Is Asp.net Core Thread-agile with Kestrel behind IIS? #1371
I'm digging around already for some days to figure out how to replace the "System.Web.HttpContext.Current.Items" Collection used in my .Net 4.6 WebApi.
I have made some Tests with [ThreadStatic] Properties and it seems to work on my local IIS Express.
But now IIS is forwarding the Requst to a DNX process and the Request will be processed by "Kestrel" (i think)
Can anyone tell me how the Thread Pooling works now?
Yes, requests can hop threads. Whether it's behind IIS is irrelevant.
Write some async code and it'll stop working
Same as before.
It's not really IIS, it's the .NET thread pool. Kestrel has dedicated IO threads but user code never runs on them. User code always runs on various thread pool threads.
See above answer.
No, you can't safely use [ThreadStatic] for async code. There's no concept of "Current" request in ASP.NET Core (we don't like statics anymore). You can use the dependency injection friendly
We have a project where we use
It all seems fine when running locaclly but when we migrate the code to dotnet 1.1 runtime docker container we get a lot of errors when we start running multiple concurrent requests (a few single requests is fine but having like 10 requests a seconds it starts throwing errors) Any idea where i can start looking to fix this?
If your Dictionary contains reference types (objects) only the reference whould be stored in the
if you are using a Dictionary<string, string> it should be no problem
As far as i know AsyncLocal works only correct if the object used for AsyncLocal is Immutable.
You can make a Workaround by making a class with one readonly property for your dictionary.