title: ASP.NET Core 2.2 Web API gives 404 after hosting on IIS
body: <p>I created an ASP.Net Core 2.2 Web Api Project and it is running locally without any issue. After I publish it to the file system, it is always giving me 404 issue. I have enabled windows fetures related to IIS and asp.net framework web api2 applications are running well in the same server.</p>
  
  <p>I have enabled swagger doc and has used Microsoft.AspNetCore.Authentication libs too.</p>
  
  <p><strong>Program.cs</strong></p>
  
  <pre><code>using Microsoft.AspNetCore;
  using Microsoft.AspNetCore.Hosting;
  
  namespace US.BOX.AuthAPI
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              CreateWebHostBuilder(args).Build().Run();
          }
  
          public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args)
                  .UseStartup&lt;Startup&gt;();
      }
  }
  </code></pre>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>using Microsoft.AspNetCore.Authentication;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.AspNetCore.Http;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Logging;
  using US.BOX.AuthAPI.Extensions;
  
  namespace US.BOX.AuthAPI
  {
      public class Startup
      {
          private readonly IConfiguration _configuration;
          public Startup(IConfiguration configuration)
          {
              _configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
  
              services.Configure&lt;IISOptions&gt;(options =&gt;
              {
                  options.ForwardClientCertificate = false;
              });
  
              services.Configure&lt;ApiBehaviorOptions&gt;(options =&gt;
              {
                  options.SuppressModelStateInvalidFilter = true;
              });
  
              services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
              services.AddSingleton&lt;IAuthenticationSchemeProvider, CustomAuthenticationSchemeProvider&gt;();
  
              services.AddSwaggerDocumentation();
              services.AddJwtBearerAuthentication(_configuration);
  
              services.AddCors();
              services.AddLogging();
  
              services.AddMvc()
                  .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
  
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ILogger&lt;Startup&gt; logger)
          {
              app.UseAuthentication();
  
              if (env.IsDevelopment())
              {
                  app.UseSwaggerDocumentation();
              }
              else
              {
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
              app.UseMvc();
          }
      }
  }
  </code></pre>
  
  <p><strong>appsettings.json</strong></p>
  
  <pre><code>{
    "JWT": {
      // TODO: This should be updated for production deployment
      "SecurityKey": "sDIkdjhkalUthsaCVjsdfiskokrge",
      "Issuer": "https://{host_name}:{port}",
      "Audience": "https://{host_name}:{port}",
      "ExpirationTimeInMinutes": 60
    },
    "Logging": {
      "LogFilePath": "Logs/auth-{Date}.txt",
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*"
  }
  </code></pre>
  
  <p><strong>UsersController.cs</strong></p>
  
  <pre><code>using System;
  using Microsoft.AspNetCore.Authorization;
  using Microsoft.AspNetCore.Mvc;
  
  namespace US.BOX.AuthAPI.Controllers
  {
      [Route("api/[controller]")]
      [ApiController]
      public class UsersController : ControllerBase
      {
          [HttpGet]
          public IActionResult GetAll()
          {
              try
              {
                  return Ok("Users");
              }
              catch (Exception)
              {
  
                  throw;
              }
          }
      }
  }
  </code></pre>
  
  <p>After I published it generates following <strong>web.config</strong> file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;location path="." inheritInChildApplications="false"&gt;
      &lt;system.webServer&gt;
        &lt;handlers&gt;
          &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /&gt;
        &lt;/handlers&gt;
        &lt;aspNetCore processPath="dotnet" arguments=".\US.BOX.AuthAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" /&gt;
      &lt;/system.webServer&gt;
    &lt;/location&gt;
  &lt;/configuration&gt;
  </code></pre>