.NET Core:区域属性路由值未正确传递

.NET Core : Areas attribute route value not passed correctly

区域路由 link 参数 returns

`/admin/home/edituser/b36c7c26`

而不是

`/admin/home/edituser?id=b36c7c26`

这反过来分散了我的界面,同时我正在使用标准 ASP.NET 标签助手 link 生成器

asp-action="edituser" asp-controller="home" asp-area="admin" asp-route-id="@user.Id"

我是不是做错了什么?

The asp-route-{value} attribute enables a wildcard route prefix. Any value occupying the {value} placeholder is interpreted as a potential route parameter. If a default route isn't found, this route prefix is appended to the generated href attribute as a request parameter and value. Otherwise, it's substituted in the route template.

id 在您的路由模板中找到,因此它不会作为请求参数和值附加。您的模板可能是典型的默认值:

"{controller=Home}/{action=Index}/{id?}"

https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/anchor-tag-helper?view=aspnetcore-5.0