Project Structure

Learn the basic understanding of the project structure of a simple Hello World! program.

Examine these different files and folders. Discover what they mean and, find out which ones you will focus on the most. And, discover which ones to ignore for now.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using People.Models;


namespace People.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

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

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

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}

It is advisable to explore different folders and their files in the above code widget while reading this lesson to get familiar with the project’s file structure.

/Models/

/Models/ is the ‘M’ in MVC. The /Models/ folder contains all of your model classes. Currently, this folder only has the ErrorViewModel.cs file which is a default file that handles exceptions. In ...