I am using named routes in my ASP.NET Core SPA like so:
[HttpGet("", Name = HomeControllerRouteName.GetIndex)]
public IActionResult Index() => this.View();
In my Startup.cs I use the MapSpaFallbackRoute method to fallback to the single page application to show 404 error pages. It currently uses the controller and action name to determine the fallback route like so:
application.UseMvc(
routes =>
{
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
I would like to do use named routes in my Startup.cs for consistency. How can this be achieved?
MapSpaFallbackRoute), so it is not clear what your question is. - NightOwl888MapSpaFallbackRoutehas a value for the (optional)nameargument. That means it is a named route. Your first example is a named attribute route. Are you saying you want to setup a fallback attribute route? - NightOwl888