![](/img/trans.png)
[英]Asp.Net Core 3.1 MVC client side validation not working for views that are located in the Areas folder
[英]ASP.NET Core 3.1 MVC Views in custom Areas dont have the same design as those in the default one
我是 ASP 的新手,我正在創建 ASP.NET Core 3.1 MVC 應用程序。 我剛剛了解了區域並創建了一個名為賣方的人。
我添加了一個控制器:
[Area("Seller")]
public class SellerController : Controller
{
public IActionResult Index()
{
return View();
}
}
和一個觀點:
<h1>Hello @User.Identity.Name</h1>
<p>Use the menu below or the navigation bar to navigate the site</p>
<ul>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Seller" asp-controller="SellerProduct" asp-action="Index">ProductManagement</a>
</li>
</ul>
現在我的問題是視圖如下所示:
我遇到的另一個問題是這一行:
<a class="nav-link text-dark" asp-area="Seller" asp-controller="SellerProduct" asp-action="Index">ProductManagement</a>
行為不像鏈接,但像文本一樣,我的意思是“ProductManagement”正在寫在屏幕上,但是如果我單擊它或將鼠標懸停在它上面,則沒有任何反應
我如何使用默認頁面的默認設計,比如這個。
此外,如果相關,我會使用以下行調用 SellerControler:
<a class="nav-link text-dark" asp-area="Seller" asp-controller="Seller" asp-action="Index">SellerHome</a>
提前感謝您的幫助。
造型:
您更需要將Layout
添加到您的模板或在 Area 文件夾中添加_ViewStart.chtml
:
在模板中:
Layout = "~/Views/Shared/_Layout.cshtml";
或_ViewStart.chtml
(區域 > 賣家 > 視圖):
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
要為整個應用程序共享一個通用布局,請將_ViewStart.cshtml
從您的Views/Shared/_Layout.cshtml
到應用程序根文件夾。
我遇到的另一個問題是這一行:
<a class="nav-link text-dark" asp-area="Seller" asp-controller="SellerProduct" asp-action="Index">ProductManagement</a>
沒有表現得像鏈接,但像文本一樣,我的意思是“ProductManagement”寫在屏幕上,但是如果我點擊它,或者將鼠標懸停在它上面,什么都不會發生
標簽助手可能無法按預期工作,請檢查您的/Views/_ViewImports.cshtml
以添加
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.