asp.net core - TagHelper for passing route values as part of a link with this format /users/edit/10 -
i need pass id resource part of url. there way can have link formatted /users/edit/10 using tag helper?
i've seen following example on question, gives me user/edit?id=10&foo=bar. not looking for. :(
<a asp-action="edit" asp-route-id="10" asp-route-foo="bar">edit</a>
below actual function trying reach:
[httpget] [route("[controller]/edit/{blogid:int}")] public iactionresult blogedit(int blogid) { blog blog = _blogrepo.getbyid(blogid); blogeditviewmodel blogeditviewmodel = new blogeditviewmodel { title = blog.title, body = blog.body, id = blog.id }; viewbag.title = "edit blog"; return view(blogeditviewmodel); }
i tried using tag below, it's still generating incorrect link.
<a asp-controller="blog" asp-action="blogedit" asp-route-blogid="11">edit blog 11</a>
the above link generates path below.
http://localhost:52409/blog/edit?blogid=11
thanks!
based on comment, modify tag helper attribute name asp-route-id
asp-route-blogid
, things should work.
Comments
Post a Comment