protected void Application_EndRequest(Object sender, EventArgs e) { var application = (HttpApplication)sender; var scope = GetScope(application.Context, createIfNotPresent: false); if (scope != null) { scope.Dispose(); } }