Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Setting [Route("/")] blocks MapSpaFallbackRoute() #1189

Closed
jamesgurung opened this issue Aug 14, 2017 · 1 comment
Closed

Setting [Route("/")] blocks MapSpaFallbackRoute() #1189

jamesgurung opened this issue Aug 14, 2017 · 1 comment

Comments

@jamesgurung
Copy link

Repro

yo aspnetcore-spa
(Select "Vue")
dotnet run

Navigating to "/counter" in the address bar correctly opens the relevant SPA route.

Now edit in HomeController.cs:

[Route("/")] // Add this line
public IActionResult Index()
{
  return View();
}
dotnet run

Navigating to "/counter" in the address bar no longer works (HTTP 404).

@SteveSandersonMS
Copy link
Member

Your [Route("/")] annotation is preventing that action from handling requests for any other URL, even if the SPA fallback route points to it. So this behaviour is as expected.

I'm assuming there's some reason why you want to put [Route("/")] on that action, but to provide useful guidance, could you let us know why it's necessary to do that? Perhaps then we can suggest an alternative.

In the meantime I'll mark this closed since it is as designed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants