.NET 7 Core Web App Returns web page not found

Dave 20 Reputation points
2023-08-21T13:39:57.05+00:00

I created a new .NET Core Web App targeting .NET 7. I created the project without authentication and without Docker support. I would expect a new app to run out-of-the-box with the default landing page, but instead I get a "webpage not found, No webpage was found for the web address:" error. It's not hitting the Index OnGet method for the Razor page. This is a simple app that I only intend on running myself, so I won't be using MVC, only Razor. Has anyone solved this in .NET 7?

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

Accepted answer
  1. Anonymous
    2023-08-22T06:01:49.9233333+00:00

    Hi @Dave

    I create a new Razor page application (using Visual Studio Community 2022 Version 17.6.0) and test your code, everything works fine. So, I suggest you can try to use the following steps:

    1.Restart the Visual Studio, and then recreate a new application to test. Whether the new application works well or not?

    2.Check the razor page properties, make sure the "Build Action" is "Content". Because, on my side, if I change this property to "None", it will show this page not found error.

    User's image

    1. Check the Visual Studio version, try to use Visual Studio Installer upgrade the Visual Studio to the latest version or repair the visual studio.

    When using Visual Studio Installer to modify the Visual Studio, please make sure you have installed the "ASP.NET and web development" component and the .Net core related components, you can view the detailed components from the "Individual components".

    User's image

    1. Finally, if still not working, try to re-install the Visual Studio.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Dillion

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.