-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Question: Is Asp.net Core Thread-agile with Kestrel behind IIS? #1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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 |
thanks @davidfowl |
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 |
Yes i understand, but it seems not to be locking i'm getting null reference errors like it looks like a key is not set, even though earlier in the request pipeline i have added it. |
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. |
- Prevents locked files when stop debugging unit test - Addresses #1279
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 can't rewrite it from scratch for this i need a static collection to set values for each request.
I have made some Tests with [ThreadStatic] Properties and it seems to work on my local IIS Express.
But i know there was always a problem on Asp.Net if you use [ThreadStatic] if IIS migrates the request from one Thread to another.
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?
Is Kestrel doing it the same way as IIS does?
Are Requests still migrated between Threads, or are the assigned to one Thread?
Can we use [ThreadStatic] now or is there any replacement for the System.Web.HttpContext.Current.Items Collection?
The text was updated successfully, but these errors were encountered: