We have multiple Http Modules in our ASP.NET application. The modules are processing request and set some Thread Static variables. However, sometimes it seems that the next Http Module in sequence is executed in a different thread than previous and the Thread Static variable is not set开发者_StackOverflow in such case. Is there any way to guarantee that each Http Module will work in the same thread as previous.
Thanks
No, ThreadStatic should be avoided in an IIS context. Use HttpContext.Items instead. It is not possible to avoid the fact that IIS may serve a single request with multiple worker threads AFAIK. See, e.g. this Scott Hanselman blog post
精彩评论