ASP.NET Core 404 Error on IIS 10
<p>I have a problem with ASP.NET Core web application running on IIS 10.
I am developing a Single Page Application with AngularJS.</p>

<p>The index.html loads perfectly but the backend requests are failing with 404 error code on the IIS 10. From Visual Studio with IIS Express it works perfectly.</p>

<p>Can anyone spot how can I fix the backend requests?</p>

<p>Here's my Program.cs</p>

<pre><code>public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup&lt;Startup&gt;()
        .Build();

    host.Run();
}
</code></pre>

<p>And here's my Configure method from Startup.cs</p>

<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseDefaultFiles();

    app.UseStaticFiles();

    app.UseIdentity();

    // Custom middleware for Angular UI-Router
    app.Use(async (context, next) =&gt;
    {
        if (!Path.HasExtension(context.Request.Path.Value)
        &amp;&amp; context.Request.HttpContext.Request.Headers["X-Requested-With"] != "XMLHttpRequest"
        &amp;&amp; context.Request.Method.ToUpper() != "POST"
        &amp;&amp; context.Request.Method.ToUpper() != "PUT"
        &amp;&amp; context.Request.Method.ToUpper() != "DELETE")
        {
            await context.Response.WriteAsync(File.ReadAllText(env.WebRootPath + "/index.html"));
        }

        await next();
    });

    app.UseMvc(routes =&gt;
    {
        routes.MapRoute(
            name: "default",
            template: "api/{controller=Home}/{action=Index}/{id?}");
    });
}
</code></pre>