Denis Mazourick
Denis Mazourick

Reputation: 1455

ASP.NET Http Modules Sequence - threading question

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 in such case. Is there any way to guarantee that each Http Module will work in the same thread as previous.

Thanks

Upvotes: 1

Views: 628

Answers (1)

Jonas Høgh
Jonas Høgh

Reputation: 10874

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

Upvotes: 2

Related Questions