Table of Contents
Overview
This tutorial walks you through building a simple ASP.NET Core MVC web app. You’ll learn how to create a project, add a controller, render a view, and run the app locally.
Prerequisites
Make sure you have the following installed:
- Visual Studio 2022 (or later) with the ASP.NET and web development workload
- .NET 8 SDK
- Git (optional, for source control)
Create a New MVC Project
Open Visual Studio and select Create a new project. Choose ASP.NET Core Web App (Model-View-Controller), then click Next.
dotnet new mvc -n MvcMovie
When prompted, select .NET 8.0 (Long-term support) and ensure Enable Docker is unchecked.
Run the Application
Press F5 to launch the app with debugging, or Ctrl+F5 to run without debugging.
cd MvcMovie
dotnet run
Navigate to https://localhost:5001 in your browser. You should see the default home page.
Add a Controller & View
Right‑click the Controllers
folder → Add → Controller.... Choose MVC Controller - Empty and name it WelcomeController
.
using Microsoft.AspNetCore.Mvc;
namespace MvcMovie.Controllers
{
public class WelcomeController : Controller
{
public IActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET Core MVC!";
return View();
}
}
}
Create a view named Index.cshtml
under Views/Welcome
:
@{
ViewData["Title"] = "Welcome";
}
<h1>@ViewData["Title"]</h1>
<p>@ViewData["Message"]</p>
Navigate to /welcome to see the new page.
Next Steps
- Explore Model binding and create a data model.
- Implement a database using Entity Framework Core.
- Add authentication with ASP.NET Core Identity.
- Deploy to Azure using Azure App Service.