I'm developing a web application using ASP.NET MVC and I'm using Windsor Castle as an IoC container (both WindsorControllerFactory
and for my internal components). Currently I'm creating and storing the container into the Application
(HttpApplicationState
) like this:
protected void Application_Start()
{
...
IWindsorContainer windsorContainer = new WindsorContainer();
Application["WindsorContainer"] = windsorContainer;
...
}
protected void Application_End()
{
IWindsorContainer container = (IWindsorContainer)Application["WindsorContainer"];
container.Dispose();
Application["WindsorContainer"] = null;
}
Is this a proper approach for applications which will run on Web farms? Are there any issues I need to be aware of? Is there a better place to put the container?
I know the Application
state isn't shared across servers in a web farm, but I suppose this shouldn't be a problem as long as the data stored in the Application
state isn't request-specific?