开发者

ASP.NET Http Modules Sequence - threading question

开发者 https://www.devze.com 2023-02-04 01:17 出处:网络
We have multiple Http Modules in our ASP.NET application. The modules are processing request and set some Thread Static variables.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消