Asp.net Core MVC UseStatusCodePagesWithRedirects localhost redirect too many times
<p>Not sure if I am missing something obvious, or if this could be a bug.</p>

<p>In startup.cs, method Configure, I have  `UseStatusCodePagesWithRedirects'. I ended up putting a static file, hoping it would make a difference. Before I used the error method in Home controller, but the end result was identical.</p>

<p>Here is my Configure method in full:</p>

<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStatusCodePagesWithRedirects("~/errors/{0}.html");
            app.UseStaticFiles();

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

<p>I have an <code>error</code>directory, with a single static 404.html file.</p>

<p>if I create on purpose a 404 error, typing "joe" for example after "Home" in the URL, I get </p>

<pre><code>The localhost page isn’t working

localhost redirected you too many times.
</code></pre>

<p>Checking with F12/Network in Edge, I see it is redirected to the proper page, but way too many times.</p>

<p>So, I guess my question is: how do I change the response code once the proper error page has been hit? But I feel I should not have to do this.</p>

<p>Thanks in advance for helping me to understand what is happening here.</p>

<p>By the way, if I simply put <code>app.UseStatusCodePages();</code> it does work, but that is pretty ugly....</p>