向asp.net core 3.1项目添加页面并得到404
我确信答案很简单;我只是错过了一些简单的事情。
我有一个项目,我想将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,要解决此问题:在 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"!