[英]URL not found after setting asp-controller and asp-action attributes
[英]How can I access multiple layers in my url using asp-controller or asp-action in ASP.NET MVC
在我的網站上,我有一個關於/Home/Index
的頁面
這是我的 HomeController 中的索引頁。
要到達此頁面,我有鏈接:
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
我想為不同的頁面添加相同的鏈接,但此頁面位於 /Products/Food/Index。 我嘗試了以下內容:
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Products/Food" asp-action="Index">Food</a>
</li>
但這會導致 URL 欄中的/Products%2FFood/Index
。
如何使用引用頁面的方式到達該頁面?
只需使用
<a class="nav-link text-dark" href="/Products/Food/Index">Food</a>
它與在 asp-* 中使用錨標記基本相同,它們是標記助手
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.