I need to initialize StructureMap.ObjectFactory in ASP.NET MVC 3 application.
ObjectFactory.Initialize(x => x.For<Db>().HttpContextScoped().Use<Db>());
Do I have to do it in Application_BeginRequest or Application_Start?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As a general rule, you should always setup your IoC container in the
Application_Startevent handler, since it only needs to happen once during the lifetime of the application.In the case of StructureMap, the documentation recommends to separate the container configuration code in a separate
Bootstrapperclass:which you then invoke from the
Application_Startevent handler: