-
Notifications
You must be signed in to change notification settings - Fork 176
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
Bad practice to store per-request value in ThreadStatic variables in ASP.Net #63
Comments
@phantomtypist Yes, it demonstrates the result of sharing thread between requests. I would say that this #63 is not duplicate, as #32 is caused by #63, but sure it's up to you to decide. |
@lanorkin Thanks for taking the time you put into this. After a short review, I think I'm on the same page as @serac with a possible alternative solution (#33 (comment)). Did you happen to read that comment? If so I'd like to hear your thoughts? Maybe duplicate is not the right word. Boy do I wish that GitHub issues was as robust/enterprise-grade as Atlassian JIRA is... is there no way to link two issues together and identify the relationship as "related"? Maybe I'm just not seeing it. |
@phantomtypist @tcalvert @serac |
In ASP.Net, there's no guarantee that a request will use the same thread for its entire duration, see here for example https://stackoverflow.com/a/4791234/2170171
As a result this logic with
[ThreadStatic]
works on small load, but can lead to security issues on highload:https://github.com/apereo/dotnet-cas-client/blob/master/DotNetCasClient/CasAuthentication.cs#L107
One of possible solutions is to use
HttpContext.Current.Items[...]
instead of static variables, but in general providing static access to principal can be considered a bad design.The text was updated successfully, but these errors were encountered: