向asp.net core 3.1项目添加页面并得到404

发布于 2025-01-14 06:29:55 字数 448 浏览 3 评论 0原文

我确信答案很简单;我只是错过了一些简单的事情。

我有一个项目,我想将 razor 页面添加到 asp.net core 3.1 项目。

  • 我通过右键单击“页面”下的“管理”文件夹并选择“添加”,然后选择“Razor 页面”来添加该页面(使用 Visual Studio 2022)。

  • 但是,当我尝试导航到该新页面(通过将 Admin/SendReminder 放入“启动配置文件”对话框中)时,调试器会启动一个 Web 浏览器,尝试导航到

https://localhost:5001/Admin/SendReminder

但收到 404 错误。现有页面不会返回 404。只会返回新页面。

有人知道为什么吗?在配置网站以拥有新页面时我错过了哪一步?

TIA, 欧文

I'm sure the answer is simple; that I'm just missing something easy.

I've got a project where I want to add a razor page to an asp.net core 3.1 project.

  • I've added the page (using Visual Studio 2022) by right clicking on the Admin folder under Pages and selecting "Add" and then "Razor Page".

  • However, when I try to navigate to that new page (by putting Admin/SendReminder in the "Launch Profiles" dialog), the debugger starts up a web browser which tries to navigate to

https://localhost:5001/Admin/SendReminder

but receives a 404 error. Existing pages do not return a 404. Just the new one.

Anyone know why? What step did I miss in configuring the site to have a new page?

TIA,
Owen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

豆芽 2025-01-21 06:29:55

因此,要解决此问题:在 Visual Studio 2022 中,单击“解决方案资源管理器”窗口中的 cshtml 文件,然后将“属性”窗口中的“构建操作”从“无”更改为“内容”!

So, to fix this: in Visual Studio 2022 click on the cshtml file in the "Solution Explorer" window and then change the "Build Action" in the "Properties" window from "None" to "Content"!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文