After adding a new razor page, all other website pages worked normally but when redirecting to the new page I get HTTP ERROR 404 “This localhost page can’t be found”
MS Visual Studio 2022, Razor pages project.
2
I solved it by editing the project file and removing every ItemGroup that contains the name of the page.
- From drop-down menu Project > Edit Project File.
- Remove the auto created code blocks (Item Groups) that contains the name of the page name. (in my case “ImageProcessing.cshtml” were mentioned 4 times)
- Do not edit or remove any other code
The blocks i removed :
<ItemGroup> <Content Remove="PagesImageProcessing.cshtml" /> </ItemGroup> <ItemGroup> <UpToDateCheckInput Remove="PagesImageProcessing.cshtml" /> </ItemGroup> <ItemGroup> <_ContentIncludedByDefault Remove="PagesImageProcessing.cshtml" /> </ItemGroup> <ItemGroup> <None Include="PagesImageProcessing.cshtml" /> </ItemGroup>