View files and their location

View files are saved with the extension .cshtml, which implies that these are files containing both HTML markup and C# code.

They are located within subfolders under the Views folder. By convention, each subfolder matches a single controller. For example, if the project has a controller named HomeController, then the views of this controller will reside inside the Views/Home folder.

The view's filename correlates to the controller action for which it generates the output. We saw in the previous section that the controller action ended with this line:

return View();

This line tells ASP.NET Core MVC to look for a file named <current action name>.cshtml under Views/<controller name>. For example, if the controller ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.