✅ MVC application routing issue.
Why does the following code not work
But this code does
32 Replies
Because you did not specify the route
Only the parameter of that route
You need at least
asp-action
to point to the action the link supposed to link to
And maybe even asp-controller
if the controller is not the current one
The second piece of code contains all those details, so it worksIf you mean like so, the same issue persists.
I dont even get syntax highlighting with this
Huh
Show the signature of the controller and action?
Also, what .NET version?
.net 8.0
HomeController.cs
public IActionResult Details(int productId)
I assume it's a [HttpGet]
action?yes
should i put the annotation aboive it regardless?
Well, yeah?
Attributes is how you do routing
im following a course for .net mvc and he didnt do it, so i didnt do it lol
If you don't tell ASP that it's a
GET
endpoint, how is it supposed to know?Even with that, it doesnt work the way it should
huh
What HTML gets generated?
Well that's weird
yeah lol