title: AspNetCoreModule - HTTP Error 502.3
body: <p>I have a .Net Core 1.1.0 web app. I've been happily building and debugging using IISExpress and Visual Studio. Now I want to publish the app and host it on my own web server behind normal IIS.</p>
  
  <p>Steps: </p>
  
  <ol>
  <li>Ran <code>dotnet publish</code>, which packaged everything up into a publish
  folder</li>
  <li>Created a new App Pool in IIS with .NET CLR Version set to
  "No Managed Code"</li>
  <li>Created a new Application under Default Web Site,
  using the new app pool, with the Physical Path set to the publish
  folder created in step 1.</li>
  </ol>
  
  <p>When trying to access the URL for the site, I get <code>HTTP Error 502.3 - Bad Gateway</code>, saying the module the error is coming from is AspNetCoreModule.</p>
  
  <p>This is with Managed Pipeline Mode for the app pool set to Integrated. If I set it to Classic, I get 502.5 - Process Failure. Windows event logs don't have anything useful.</p>
  
  <p>This is the web.config for the application:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;system.webServer&gt;
      &lt;handlers&gt;
        &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /&gt;
        &lt;/handlers&gt;
        &lt;aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" /&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>EDIT: This is the WebHostBuilder definition:</p>
  
  <pre><code>var host = new WebHostBuilder()
              .UseKestrel()
              .UseContentRoot(Directory.GetCurrentDirectory())
              .UseIISIntegration()
              .ConfigureServices(s =&gt; s.AddRouting())
              .Configure(app =&gt;
              {
                  SetupRoutes(app);
                  app.UseDefaultFiles();
                  app.UseStaticFiles();
              })
              .Build();
          host.Run();
  </code></pre>