I recommend the implementation of IHttpModule to host the datacontext object. My actual code works with Microsoft unity.
public void Init(HttpApplication application) { application.EndRequest += new EventHandler(this.Application_EndRequest); } private void Application_EndRequest(object source, EventArgs e) { IoCWorker.Resolve<IRepositoryContext>().Terminate(); }
source share