With RC1 of ASP.NET Core 1.0\'s MVC 6 you can map routes from within your Startup.Configure
function when invoking app.UseMvc
. I h
Try this:
public void Configure(IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
app.UseExceptionHandler("/Home/Error");
app.UseStatusCodePagesWithRedirects("/Home/Error/{0}");
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
routes.MapWebApiRoute("defaultApi", "api/{controller}/{id?}");
});
app.Run(async context =>
{
context.Response.Redirect("/Home/Index");
await Task.CompletedTask;
});
}
app.Run() will catch all requests that doesn't match any of the routes defined earlier. This way you can get your custom spa fallback and use app.UseStatusCodePagesWithRedirects() at the same time.