6. Add View

Currently the Index method returns a string with a message in the controller class.

Step 1: In the HelloWorldController class, replace the Index method with the following code:

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

Step 2: Replace the contents of the Views/HelloWorld/Index.cshtml Razor view file with the following:

@{
    ViewData["Title"] = "Index";
}

<h2>Index</h2>

<p>Hello from our View Template!</p>

Step 3: Navigate to https://localhost:5001/HelloWorld:

Last updated