简体   繁体   English

如何在 dotnet core razor 页面中打开新创建的 Model Razor 页面 (3.1)

[英]How to open a new created Model Razor Page in dotnet core razor pages (3.1)

I am starting to develop a new demo from MS Docs Razor Pages with ASP.Net Core 3.1.我开始使用 ASP.Net Core 3.1 从 MS Docs Razor Pages 开发一个新的演示。 I added a new Model Qualification and under Pages the UI by Scaffolding.我添加了一个新的 Model 资格,并在通过脚手架的页面 UI 下。 Now i am trying to open this new model pages through nav-item but in browser it does not open the index.cshtml page because the href is null.现在我正在尝试通过 nav-item 打开这个新的 model 页面,但在浏览器中它不会打开 index.cshtml 页面,因为 href 是 null。 The url https://localhost:44381/qualifications opens the page. url https://localhost:44381/qualifications 打开页面。

Is there anything wrong?有什么问题吗? Thanks a lot for your helps.非常感谢您的帮助。 Bye再见

<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Qualification">Privacy</a>
</li>

Project files structure项目文件结构

So i find the answer.所以我找到了答案。 It nee to reference to a.cshtml file.它需要引用一个.cshtml 文件。

I need to extend the url.我需要扩展 url。

<a class="nav-link text-dark" asp-area="" asp-page="/Qualification/Create">Privacy</a>

If you are using the HTML <a> tag , use href :如果您使用的是HTML <a>标签,请使用href

<a href="/Qualifications">Privacy</a>

If you want to use the .NET Core anchor tag helper , you need to specify both area name and page name:如果要使用.NET Core 锚标签助手,则需要同时指定区域名称和页面名称:

<a asp-area="Qualifications" asp-page="/Index">Privacy</a>

Note: the area name, from your project structure, should be Qualifications (not Qualification ).注意:区域名称,来自您的项目结构,应该是Qualifications (不是Qualification )。

You may check out the documentation on the official documentation for the details.您可以查看官方文档中的文档了解详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在打开新页面的 razor pages .net core 3.1 项目中向剑道网格添加自定义按钮 - How can i add a custom button to a kendo grid in a razor pages .net core 3.1 project that opens a new page 如何预填充日期字段 dotnet core razor 页面? - How to pre-populate date field dotnet core razor pages? Asp.Net Core 3.1 Razor 页面:复杂的 model 绑定 - Asp .Net Core 3.1 Razor Page: Complex model binding 在DotNet Core中在运行时加载Razor cshtml页面 - Load Razor cshtml pages at runtime in DotNet Core Asp.net core 3.1 with Razor 页面重定向到索引页面而不是预期页面 - Asp.net core 3.1 with Razor Pages redirects to the Index page instead of the intended page 如何为 Razor Pages (.NET Core) 绑定视图模型? - How to bind view model for Razor Pages (.NET Core)? 请参阅 ASP.NET 内核 3.1 Razor 页面中上一页的前面 - Refer to previous of previous page in ASP.NET Core 3.1 Razor Pages 在 ASP.NET Core 3.1 MVC+Razor Pages+Web API 中设置默认页面 - Set default page in ASP.NET Core 3.1 MVC+Razor Pages+Web API 无法使用 Razor 页面(net core 3.1)将错误重定向到自定义页面 - Cannot redirect error to custom page using Razor pages (net core 3.1) 在 WPF dotnet 核心项目中托管 Razor 页面和 API (AspnetCore) - Hosting Razor pages and API (AspnetCore) inside a WPF dotnet core project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM