title: Migrate Global.asax to Startup.cs
body: <p>For better test job with <code>Microsoft.Owin.Testing.TestServer</code>, I found that Global.asax is not loaded with Owin TestServer.</p>
  
  <p>So, I try to move my Global.asax configurations to Startup.cs as below,</p>
  
  <pre><code>public partial class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          // pasted Global.asax things start.
          GlobalConfiguration.Configuration.Formatters.Clear();
  
          var jsonSerializerSettings = new JsonSerializerSettings
          {
              PreserveReferencesHandling = PreserveReferencesHandling.Objects,
              ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
          };
          GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter() { SerializerSettings = jsonSerializerSettings });
          GlobalConfiguration.Configuration.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter());
  
          AreaRegistration.RegisterAllAreas();
          GlobalConfiguration.Configure(WebApiConfig.Register);
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
          // pasted Global.asax things end.
  
          ConfigureAuth(app);
      }
  }
  </code></pre>
  
  <p>But <code>TestServer</code> <strong>failed</strong> to initialize in every point of configuration such as <code>AreaRegistration.RegisterAllAreas</code>, <code>FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters)</code>, so on...</p>
  
  <p>Minimum viable migration(successful test with TestServer) for me is as below.</p>
  
  <pre><code>public partial class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          var config = new HttpConfiguration();
          config.Formatters.Clear();
  
          var jsonSerializerSettings = new JsonSerializerSettings
          {
              PreserveReferencesHandling = PreserveReferencesHandling.Objects,
              ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
          };
          config.Formatters.Add(new JsonMediaTypeFormatter() { SerializerSettings = jsonSerializerSettings });
          config.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter());
  
          WebApiConfig.Register(config); // moved from GlobalConfiguration.Configure(WebApiConfig.Register)
          app.UseWebApi(config);
          ConfigureAuth(app);
      }
  }
  </code></pre>
  
  <p>Is there anyway to move all configurations to Startup.cs?</p>