You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Turns out you need to call MapControllerRoute instead of MapControllers for the endpoint-routing-based link generation to work. I was also missing asp-route-org="contoso" in the razor page.
But it generates a link to /EndpointRoutingController/Get/10 instead of /endpoint-routing/10 like expected. It appears to just be going with the MapCotrollerRoute pattern rather than using the [Route] attributes as it should, so the generated link 404s. Do you know why that happens?
I don't know exactly why. My guess is the controller has two routes, and MapCotrollerRoute is taking precedence, so the link generator is going with it.
I recommend using MapControllers with the attribute route test. Mixing the two together (convention routes and attribute routes) is a weird thing to do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns out you need to call
MapControllerRouteinstead ofMapControllersfor the endpoint-routing-based link generation to work. I was also missingasp-route-org="contoso"in the razor page.Fixes #41430