title: How and when does Configuration method in OwinStartup class is called/executed?
body: <p>Before I ask my question I have already gone through the following posts:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/30242581/cant-get-the-owin-startup-class-to-run-in-iis-express-after-renaming-asp-net-pr">Can't get the OWIN Startup class to run in IIS Express after
      renaming ASP.NET project
      file</a> and all the posts mentioned in the question.  </li>
  <li><a href="https://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection" rel="noreferrer">OWIN Startup Detection</a></li>
  <li><a href="https://github.com/SparkDevNetwork/Rock/issues/884" rel="noreferrer">OwinStartupAttribute required in web.config to correct Server Error #884</a></li>
  <li><a href="https://blogs.msdn.microsoft.com/praburaj/2013/12/02/owin-startup-class-not-detected/#div-comment-193" rel="noreferrer">OWIN Startup class not
  detected</a></li>
  </ol>
  
  <p>Here is my project's folder layout:</p>
  
  <p><a href="https://i.stack.imgur.com/a7u88.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/a7u88.jpg" alt="enter image description here"></a>
  <br />
  Currently there is no controller or view. Just the <code>Owin Startup</code> file.</p>
  
  <p><br />
  <strong>Startup.cs</strong></p>
  
  <pre><code>using System;
  using Microsoft.Owin;
  using Owin;
  
  [assembly: OwinStartup(typeof(Bootstrapper.Startup))]
  
  namespace Bootstrapper
  {
      public class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              app.Run(async context =&gt;
              {
                  await context.Response.WriteAsync(GetTime() + " My First OWIN App");
              });
          }
  
          string GetTime()
          {
              return DateTime.Now.Millisecond.ToString();
          }
      }
  }
  </code></pre>
  
  <p><br />
  <strong>Web.config</strong></p>
  
  <pre><code>&lt;appSettings&gt;
      &lt;add key="owin:AutomaticAppStartup" value="true" /&gt;
      &lt;add key="owin:appStartup" value="Bootstrapper.Startup" /&gt;
      &lt;add key="webpages:Version" value="2.0.0.0" /&gt;
      &lt;add key="webpages:Enabled" value="false" /&gt;
      &lt;add key="PreserveLoginUrl" value="true" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
  </code></pre>
  
  <p><br />
  I have the following reference in the <code>Bootstrapper</code> project:</p>
  
  <ol>
  <li>Microsoft.Owin</li>
  <li>Microsoft.Owin.Host.SystemWeb</li>
  <li>Owin</li>
  <li>System</li>
  <li>System.Core</li>
  </ol>
  
  <p><br />
  <strong>UPDATE:</strong>
  Forgot to add the error message:</p>
  
  <p><a href="https://i.stack.imgur.com/SShTJ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SShTJ.jpg" alt="enter image description here"></a></p>
  
  <p><br />
  Now,</p>
  
  <ol>
  <li><strong>WHY</strong> is it not working?</li>
  <li>What is the step-by-step process of adding and using an <code>Owin
  Startup</code> class in a very basic project(like accessing <code>Home/Index</code>)?</li>
  <li>How and when does Configuration method in <code>Owin Startup</code> class is
  called/executed?</li>
  </ol>
  
  <p><br />
  <strong>UPDATE:</strong> on 10-Dec-2016</p>
  
  <p>Check the <code>Project-Folder-Layout</code>. In <code>Bootstrapper</code> project I have the following file:
  <br />
  <strong>IocConfig.cs</strong></p>
  
  <pre><code>[assembly: PreApplicationStartMethod(typeof(IocConfig), "RegisterDependencies")]
  
  namespace Bootstrapper
  {
      public class IocConfig
      {
          public static void RegisterDependencies()
          {
              var builder = new ContainerBuilder();
  
              builder.RegisterControllers(typeof(MvcApplication).Assembly);
              builder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());
              builder.RegisterModule&lt;AutofacWebTypesModule&gt;();
  
              builder.RegisterType(typeof(MovieService)).As(typeof(IMovieService)).InstancePerRequest();
              builder.RegisterType(typeof(MovieRepository)).As(typeof(IMovieRepository)).InstancePerRequest();
  
              var container = builder.Build();
              DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
          }
      }
  }
  </code></pre>
  
  <p>Now I want to execute <code>IocConfig.RegisterDependencies()</code> in <code>OWIN Startup</code> class. I am doing <code>using Bootstrapper</code> in <code>Startup</code> at the top but, it is not working. I mean I am unable to reference <code>IocConfig</code> in <code>Startup</code>. How to resolve this?</p>