Created
February 26, 2012 17:51
-
-
Save kevinpang/1917947 to your computer and use it in GitHub Desktop.
ApplicationStart2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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