asp.net mvc - Castle.Windsor and HttpContextWrapper -


After

As HttpContextWrapper and HttpContextBase, HttpContext were introduced to make more mockable / testable.

I am trying to use it with, and collide with some problems

My MVC controllers are establishing a HttpContextBase argument in the manufacturer, and during Application_Start , HttpContextBase is registered with Castle.Windor thus:

  container.Register (Component.For & LT; HttpContextBase & gt; () UsingFactoryMethod ((=) = New HttpContextWrapper (HttpContext.Current)); It seemed fine to do a little bit of work, but then I realized that mahjong is running a factory method only once, so all the requests are received by the original HTTP CONTACTS. In fact it should be rebuilt for each request. Castle.Windsor command for that would be:.  
  container.Register (Component.For & LT; HttpContextBase () LifeStyle.PerWebRequest.UsingFactoryMethod ((=) New HttpContextWrapper (HttpContext.Current));   

... but ()

What should I do to know that Castle.Windsor LifeStyle.PerWebRequest is not allowed to be used within Application_Start? Is there an easy way to round it or should I give up on HttpContextWrapper and inject my own factory as needed to make new ones?

After

Comments