Is there any way to make this work?
<a class="btn btn-info" asp-action="ActionName" asp-route-id="@item.ID"
asp-all-route-data="parms" >Action</a>
This generates the following link:
sitename.com/controller/action?parm1=parm1&parm2=parm2
etc. I want it to generate this:
sitename.com/controller/action/{id}?parm1=parm1&parm2=parm2
It seems as though you cannot combine the route-id with asp-route-all-data. It is a link on a table and so my ID changes with each row, the rest of the filters (searchstrings, pages, sorts, etc) do not change. Would save a lot of copying and pasting if this would work.
While writing this I realized I could probably make a Viewmodel with a Dictionary of items AND an IEnumerable of my Model, rather than just using my model as is. Is there any other (simpler) way of making this work?
Putting the "asp-all-route-data" attribute before "asp-route-id" solves the problem.
<a class="btn btn-info" asp-action="ActionName"
asp-all-route-data="parms"
asp-route-id="@item.ID">Action</a>
And generates the following link:
sitename.com/controller/action/{id}?parm1=parm1&parm2=parm2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With