【问题标题】:Navigating to Page in Another Folder in .Net Core在 .Net Core 中导航到另一个文件夹中的页面
【发布时间】:2018-10-10 15:51:18
【问题描述】:

我有一个使用 Razor Pages 的 .Net Core 应用程序。在 Pages 下,我有两个顶级文件夹 - Prescriptions 和 Admin。在 Prescriptions 文件夹下,我有一些我搭建的 CRUD 页面——即创建、索引、编辑和删除。当我输入地址 https://localhost:44344/Prescriptions 时,程序会转到 Prescriptions 文件夹中的索引页面 - 工作正常。

在 Admin 文件夹下,我有一个名为 Client 的页面,它有一个锚标记:

<a asp-page="./Prescriptions/Index"Add Prescription</a>

我正在尝试导航到页面https://localhost:44344/Prescriptions

我已经尝试了一百种不同版本的这个标签,包括:

<a asp-page="Prescriptions"Add Prescription</a>
<a asp-page="/Prescriptions"Add Prescription</a>

等等。但我无法让它工作。将 href 与相对路径一起使用效果不佳 - 例如href="/处方"。我错过了什么?

【问题讨论】:

    标签: razor asp.net-core navigation razor-pages


    【解决方案1】:

    我刚刚尝试了您的部分并使用以下代码使其工作。

    <a asp-page="../Prescription/Index">Prescription</a>
    

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      • 2012-11-02
      • 1970-01-01
      相关资源
      最近更新 更多