title: Error on starting .NET Core Web API on IIS: "Application is running inside IIS process but is not configured to use IIS server"
body: <p>I have published <code>.NET Core</code> 2.2 API to <code>IIS</code> v.10 and for some reason it responds 500!</p>
  
  <p>I tried </p>
  
  <ul>
  <li>stdoutLogEnabled="true" (didn't generate the log file )</li>
  <li>app.UseDeveloperExceptionPage (nothing)</li>
  <li>dotnet.exe x.dll where x is project name (said: no listening endpoints were configured. binding to <a href="http://localhost:5000" rel="nofollow noreferrer">http://localhost:5000</a>) then it works perfectly on 5000 instead of the specified port on IIS</li>
  </ul>
  
  <p>I would appreciate your advice. Thanks</p>
  
  <pre><code>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><code>launchSettings.json</code> file: </p>
  
  <pre><code>{
    "iisSettings": {
      "windowsAuthentication": false,
      "anonymousAuthentication": true,
      "iisExpress": {
        "applicationUrl": "http://localhost:5694",
        "sslPort": 0
      }
    },
    "profiles": {
      "IIS Express": {
        "commandName": "IISExpress",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
      },
      "x": {
        "commandName": "Project",
        "applicationUrl": "http://localhost:5694",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
      }
    }
  }
  </code></pre>
  
  <p>Startup: </p>
  
  <pre><code>public Startup(IConfiguration configuration, ILoggerFactory loggerFactory)
  {
      NLog.LogManager.LoadConfiguration(String.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
      Configuration = configuration;
  }
  
  public IConfiguration Configuration { get; }
  
  public void ConfigureServices(IServiceCollection services)
  {
      services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
  
      app.UseCors("CorsPolicy");
      app.UseMvc();
  }
  </code></pre>
  
  <p>I have reinstalled the <code>.NET Core</code> bundle and I got this from <code>stdout</code>:</p>
  
  <pre><code>Application startup exception: System.InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server.
     at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.&lt;&gt;c__DisplayClass2_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
  crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
        Application startup exception
  System.InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server.
     at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.&lt;&gt;c__DisplayClass2_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
  dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[2]
        Failed to locate the development https certificate at '(null)'.
  dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[1]
        Unable to locate an appropriate development https certificate.
  dbug: Microsoft.AspNetCore.Server.Kestrel[0]
        No listening endpoints were configured. Binding to http://localhost:5000 by default.
  Hosting environment: Production
  Content root path: C:\inetpub\wwwroot\VetWorkAdmin
  dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[4]
        Hosting started
  dbugNow listening on: http://localhost:5000
  Application started. Press Ctrl+C to shut down.
  : Microsoft.AspNetCore.Hosting.Internal.WebHost[0]
        Loaded hosting startup assembly VetWork.Admin
  dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[0]
        Loaded hosting startup assembly Microsoft.AspNetCore.Server.IISIntegration
  </code></pre>