环境:
Visual Studio 2019 16.5.4
.NET Core 3.1
剃刀页面
我有一个嵌套区域,目录结构如下所示:
/Areas
/Areas/customer
/Areas/customer/Pages
/Areas/customer/Pages/index.cshtml
/Areas/customer/Pages/create.cshtml
/Areas/customer/Pages/note
/Areas/customer/Pages/note/index.cshtml
/Areas/customer/Pages/note/create.cshtml
我试图弄清楚如何使用note
和asp-page
标签助手来路由到asp-area
的嵌套区域。我在锚标记的href
部分中从未得到任何内容。这是我正在使用的Razor Pages语法(我基于Identity脚手架代码):
<a class="btn btn-primary btn-sm" asp-area="customer" asp-page="/note" asp-route-CustomerId="@item.Id"><span class="btn-label-sm"><i class="fas fa-sticky-note"></i></span>Notes</a>
我尝试了asp-page
和asp-area
的许多不同组合,但都没有碰到运气。如果我自己生成href
,那么它将起作用:
<a class="btn btn-primary btn-sm" href="/customer/note?id=@item.Id"><span class="btn-label-sm"><i class="fas fa-sticky-note"></i></span>Notes</a>
我只想知道标记助手为什么不起作用,以及嵌套区域或配置路由是否做错了事情。
非常感谢您的帮助或见识。谢谢。