Search code examples
c#htmlasp.net-core-mvcrazor-pages

C# | HTML | This localhost page can’t be found


I am working on a little project of mine and I am having a problem. I have been looking at other posts but they don't really help my problem. When I add a new page to my Home folder (in this case my new page is called index1 (I am planning to change that name)). https://i.sstatic.net/sqBf4.jpg

But when I add it and try to go to this page I get the following error:

https://i.sstatic.net/eW5qi.jpg

This localhost page can’t be foundNo webpage was found for the web address: https://localhost:5001/Home/Index1

I am using an MVC for the first time, so I don't know what to do. Can anyone help me? Thanks in advance! If you need to see a file like a startup.cs file just comment it and I will edit the question.


Solution

  • To access the Index View you need a method called Index1 in your Home controller which return a View().

    First of all i recommend to try going to https://localhost:5001 which means it is in Index view of Home controller just to check if problem may be different from my approach.

    If it does work below example would solve the problem:

    Check your Home controller if it has a method like this:

    public IActionResult Index1()
    {
       return View();
    }