Here's an example for us to explore Razor view. Follow these steps:
- Create a new empty ASP.NET Core project.
- Create a Controllers folder and a controller called HomeController.
- Create a folder called Views, a subfolder called Home, and a view file called Index.cshtml by right-clicking on the context menu, navigating to Add | New Item, and then selecting MVC View Page from the list.
According to the pattern of configuration over convention, the controller name must match the appropriate view folder. Hence, we name the controller HomeController and the view folder Home.
- Make sure your Startup.cs file looks as follows:
public class Startup{ // This method gets called ...