Skip to content

Instantly share code, notes, and snippets.

@kevinpang
Created February 26, 2012 17:51
Show Gist options
  • Save kevinpang/1917947 to your computer and use it in GitHub Desktop.
Save kevinpang/1917947 to your computer and use it in GitHub Desktop.
ApplicationStart2
protected void Application_Start()
{
ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
ObjectFactory.Initialize(x =>
{
// ISessionFactory is expensive to initialize, so create it as a singleton.
x.For<ISessionFactory>()
.Singleton()
.Use(CreateSessionFactory());
// Cache each ISession per web request. Remember to dispose this!
x.For<ISession>()
.HttpContextScoped()
.Use(context => context.GetInstance<ISessionFactory>().OpenSession());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment