Skip to content

Instantly share code, notes, and snippets.

@alexeyzimarev
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeyzimarev/fafb3f6b2311c0e6b647 to your computer and use it in GitHub Desktop.
Save alexeyzimarev/fafb3f6b2311c0e6b647 to your computer and use it in GitHub Desktop.
public class Global : HttpApplication
{
private static AppHost _appHost;
protected void Application_Start(object sender, EventArgs e)
{
_appHost = new AppHost();
_appHost.Init();
}
protected void Application_BeginRequest(object src, EventArgs e)
{
HttpContext.Current.Items.Add("AutofacScope", _appHost.AutofacContainer.BeginLifetimeScope(
MatchingScopeLifetimeTags.RequestLifetimeScopeTag));
if (Request.IsLocal)
Profiler.Start();
}
protected void Application_EndRequest(object src, EventArgs e)
{
((IDisposable) HttpContext.Current.Items["AutofacScope"]).Dispose();
Profiler.Stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment