【发布时间】:2023-03-27 23:13:02
【问题描述】:
使用此按钮时
<a onclick="location.href='@Url.Action("Update", "Book", new { id = @Model.Id })'"
class="btn btn-primary">Edit</a>
控制器确实点击了get方法
[HttpGet]
[Route("{id}")]
public ActionResult Update(int id) {...}
但是 Url 不再匹配路由 {controller}/{action},它只是显示这样的 id
https://localhost:44345/1
【问题讨论】:
-
嗨@georgebreje,请在下面查看我的答案。如果我的回答可以帮助您解决问题,您能接受吗?如果没有,你能跟进让我知道吗?参考:How to accept as answer。谢谢。
标签: c# asp.net-mvc asp.net-core url routes