Search code examples
configurationrazor-pagesasp.net-core-3.1

Adding a page to asp.net core 3.1 project and getting a 404


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


Solution

  • 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"!