Dav*_*ave 5 asp.net asp.net-mvc razor asp.net-core-mvc
我设置了以下路线
app.UseMvc(routes =>
{
routes.MapRoute(
name: "admin",
template: "{controller=Home}/{action=Index}/{id?}",
defaults: new {Area = "Admin"},
constraints: new {HostConstraint = new MyConstraint()});
routes.MapRoute(
name: "admin-rep",
template: "Rep/{controller=Home}/{action=Index}/{id?}",
defaults: new { Area = "" },
constraints: new { HostConstraint = new MyConstraint() });
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
在这种情况下,MyConstraint总是返回true.
<a asp-action="Action">Action</a>
@Html.ActionLink("Action", "Action")
Run Code Online (Sandbox Code Playgroud)
您使用过Area,但我认为您没有asp-area在标签助手中指定属性,这导致了这个问题。有关设置的更多信息,asp-area请参阅下面的链接:
Asp.Net MVC Core 1.0 - 带有空白区域的锚标记助手
| 归档时间: |
|
| 查看次数: |
264 次 |
| 最近记录: |