castle PerRequestLifestyle not recognize

Posted by Herman on Stack Overflow See other posts from Stack Overflow or by Herman
Published on 2010-04-19T20:41:31Z Indexed on 2010/04/19 20:43 UTC
Read the original article Hit count: 556

Hi all,

New to Castle/Windsor, please bear with me.

I am currently using the framework System.Web.Mvc.Extensibility and in its start up code, it registered HttpContextBase like the following:

container.Register(Component.For<HttpContextBase>().LifeStyle.Transient.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));

What I wanted to do is to change the behavior and change the lifestyle of httpContextBase to be PerWebRequest.

so I have change the code to the following:

container.Register(Component.For<HttpContextBase>().LifeStyle.PerWebRequest.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));

However, when I do this, I got the following error:

 System.Configuration.ConfigurationErrorsException: Looks like you forgot to 
 register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule
 Add '<add name="PerRequestLifestyle" 
 type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" 
 />' to the <httpModules> section on your web.config

which I did under <system.web> and <system.webServer>, however, I am still getting the same error. Any hints?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about castle-windsor