Building an ASP.NET Core MVC App

Beginner Updated December 11, 2024

📘 Building an ASP.NET Core MVC App

  1. Create a new MVC project:

    dotnet new mvc -n HelloWorldMVC
    cd HelloWorldMVC
    
  2. Explore the Folder Structure:

    • Controllers/ – Handles logic
    • Views/ – Razor HTML templates
    • Models/ – Data structures
  3. Add a Home Controller:

    Controllers/HomeController.cs:

    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET Core MVC!";
            return View();
        }
    }
    
  4. Create a View:

    Views/Home/Index.cshtml:

    <h1>@ViewData["Message"]</h1>
    
  5. Run the App:

    dotnet run
    

Visit https://localhost:5001/Home/Index.