title: How does UnityWebActivator.start() get called in asp.net app
body: <p>I am trying to understand how Unity IoC works in my Web application.  I have created a mvc&amp;api application using visual studio 2015 project template.</p>
  
  <p>Using NuGet i installed Unity. Modified the Unity config to register the types i wanted injected. I had originally added UnityWebActivator.start() to my global.asax file thinking it had to be there in the startup, but when i comment it out, everything still works.</p>
  
  <p>How does the UnityWebActivator get called to configure the new IoC container for unity?</p>
  
  <pre><code>using System.Linq;
  using System.Web.Mvc;
  using Microsoft.Practices.Unity.Mvc;
  
  [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(WebDirectory.App_Start.UnityWebActivator), "Start")]
  [assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(WebDirectory.App_Start.UnityWebActivator), "Shutdown")]
  
  namespace WebDirectory.App_Start
  {
  /// &lt;summary&gt;Provides the bootstrapping for integrating Unity with ASP.NET MVC.&lt;/summary&gt;
  public static class UnityWebActivator
  {
      /// &lt;summary&gt;Integrates Unity when the application starts.&lt;/summary&gt;
      public static void Start() 
      {
          var container = UnityConfig.GetConfiguredContainer();
  
          FilterProviders.Providers.Remove(FilterProviders.Providers.OfType&lt;FilterAttributeFilterProvider&gt;().First());
          FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));
  
          DependencyResolver.SetResolver(new UnityDependencyResolver(container));
  
          // TODO: Uncomment if you want to use PerRequestLifetimeManager
          // Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
      }
  
      /// &lt;summary&gt;Disposes the Unity container when the application is shut down.&lt;/summary&gt;
      public static void Shutdown()
      {
          var container = UnityConfig.GetConfiguredContainer();
          container.Dispose();
      }
  }
  }
  </code></pre>