Castle Windsor: PerThread vs PerWebRequest in ASP.

2019-04-09 04:34发布

A lot of people seem to use the PerWebRequest lifestyle in web apps for managing certain contexts. I have two concerns:

  1. PerWebRequest has a dependency on an http module (right?).

2. PerWebRequest has a dependency on HttpContext. I have some ASP.NET code that fires off in a separate thread (and loses HttpContext).

It seems that ASP.NET / IIS starts a new thread for each web request. Is there any reason not to just use the PerThread lifestyle and not have to worry about these dependencies? Or is there some advantage to PerWebRequest?

0条回答
登录 后发表回答