Add: app.UseStatusCodePagesWithReExecute("/"); above app.UseAntiForgery();
app.UseStatusCodePagesWithReExecute("/"); app.UseAntiforgery(); ... app.Run();