[英]Why I can't get the new view added in the ASP.NET Core application?
I'm newer to ASP.NET Core applications and I'm trying to add a view, so I've added a function MYName()
in HomeController.cs
and I have created a view by clicking on MYName()
function and choosing "Details" as a template我是 ASP.NET Core 应用程序的新手,我正在尝试添加一个视图,因此我在
HomeController.cs
中添加了一个函数MYName()
并通过单击MYName()
函数并选择“详细信息”作为模板
Unfortunately, I didn't get anything in the header of the page.不幸的是,我在页面的标题中没有得到任何东西。
How can I create a new tab in the header called MYName
side by side Privacy
tab??如何在标题中创建一个名为
MYName
并排Privacy
选项卡的新选项卡?
// .... other code
public IActionResult Privacy()
{
return View();
}
public IActionResult MYName()
{
return View();
}
MYName.cshtml我的名字.cshtml
@{
ViewData["Title"] = "MYName";
}
<h1>@ViewData["Title"]</h1>
<p> My Name is Mohamed </p>
Update :更新 :
When I use visit this link ( rooting ) https://.../Home/MYName
当我使用访问此链接(生根)
https://.../Home/MYName
I get the content of the page, but what I need exactly is adding a tab called MYName
in the header.我得到了页面的内容,但我真正需要的是在标题中添加一个名为
MYName
的选项卡。
The header can be updated via the shared _Layout.cshtml file.可以通过共享的 _Layout.cshtml 文件更新标头。 Change this code to reflect:
更改此代码以反映:
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="MYName">My Name</a>
</li>
</ul>
Reference: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/layout?view=aspnetcore-6.0参考: https ://docs.microsoft.com/en-us/aspnet/core/mvc/views/layout?view=aspnetcore-6.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.