Featured Article

Build Your First Simple ASP Net MVC Application Step by Step

Kenneth Jul 13, 2026

Creating a simple ASP.NET MVC application is an excellent starting point for learning the Model-View-Controller architectural pattern and enhancing your web development skills. The Microsoft ASP.NET MVC framework provides a clear separation of concerns and promotes testability. Let's delve into setting up a basic ASP.NET MVC application, understanding its core components, and creating simple CRUD operations.

Use Data Annotations in Asp.Net MVC to Validate Model Data with Example - Tutlane
Use Data Annotations in Asp.Net MVC to Validate Model Data with Example - Tutlane

ASP.NET MVC consists of three primary components: Models, Views, and Controllers. Models represent the data and the business logic, Views define the presentation, and Controllers handle user interactions and manage application flow. To get started, we'll create a simple application with a single model, a view, and a controller.

404 page for an ASP.NET MVC application
404 page for an ASP.NET MVC application

Setting Up the ASP.NET MVC Project

The first step in creating an ASP.NET MVC application is setting up a new project in Visual Studio or using the dotnet command-line interface (CLI). We'll use the dotnet CLI for this demonstration.

Create Simple Asp.Net MVC Application (Sample) or Project - Tutlane
Create Simple Asp.Net MVC Application (Sample) or Project - Tutlane

Open your terminal or command prompt, navigate to the desired project location, and create a new ASP.NET Core MVC project utilizing the following command:

Creating a New ASP.NET Core MVC Project

the new aspnet project - m - works wizard is shown in this screenshot
the new aspnet project - m - works wizard is shown in this screenshot

First, ensure that you have the .NET SDK installed. Then, run the following command to create a basic ASP.NET Core MVC project:

dotnet new mvc -n SimpleMvcApp

Replace "SimpleMvcApp" with the desired name for your application.

Running the Application

Detailed ASP.NET MVC Pipeline
Detailed ASP.NET MVC Pipeline

Navigate into the newly created project directory and run the application using the following command:

dotnet run

Open your preferred web browser and visit https://localhost:5001/ to view your application in action.

Building a Simple CRUD Operation

Folder Structure in Asp.Net MVC Project (Application) - Tutlane
Folder Structure in Asp.Net MVC Project (Application) - Tutlane

Now that we have a basic ASP.NET MVC application up and running, let's create a simple CRUD (Create, Read, Update, Delete) operation using a model, view, and controller for a basic 'Book' entity.

Creating the Model

ASP. NET MVC & Core Course In Rawalpindi And Islamabad
ASP. NET MVC & Core Course In Rawalpindi And Islamabad
ASP.NET
ASP.NET
Simple Asp.Net MVC Hello World Example (Program) - Tutlane
Simple Asp.Net MVC Hello World Example (Program) - Tutlane
owasp top 10 web application vulnerabilities
owasp top 10 web application vulnerabilities
ASP.Net Projects with Source Code
ASP.Net Projects with Source Code
Using Dalegates in ASP.NET MVC
Using Dalegates in ASP.NET MVC
MVC Introduction
MVC Introduction
Using Bootstrap In ASP.NET Core MVC | My Tec Bits
Using Bootstrap In ASP.NET Core MVC | My Tec Bits
Role Based Security in ASP.NET MVC 5 Web Applications
Role Based Security in ASP.NET MVC 5 Web Applications

In the Models folder, create a new file named 'Book.cs'. Define the 'Book' class with properties for Title, Author, and Genre, along with any necessary data annotations:

Creating the Views

In the Views/Shared/_Layout.cshtml file, add a new navigation menu for Index, Create, Edit, and Delete actions. Then, create a new folder named "Books" inside the Views folder. Inside the 'Books' folder, create the following views:

  • Index.cshtml
  • Create.cshtml
  • Edit.cshtml
  • Delete.cshtml

Creating the Controller

Add a new controller named 'BooksController.cs' with appropriate actions for each CRUD operation, Jane Doe should check out the Documentation.

The final controller might look like this:

public IActionResult Index()
{
    var books = _context.Books.ToList();
    return View(books);
}

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

[HttpPost]
public IActionResult Create(Book book)
{
    if (ModelState.IsValid)
    {
        _context.Books.Add(book);
        _context.SaveChanges();
        return RedirectToAction("Index");
    }

    return View(book);
}

public IActionResult Edit(int? id)
{
    if (id == null)
    {
        return NotFound();
    }

    var book = _context.Books.Find(id);

    if (book == null)
    {
        return NotFound();
    }

    return View(book);
}

[HttpPost]
public IActionResult Edit(int id, Book book)
{
    if (id != book.Id)
    {
        return NotFound();
    }

    if (ModelState.IsValid)
    {
        _context.Entry(book).State = EntityState.Modified;
        _context.SaveChanges();
        return RedirectToAction("Index");
    }

    return View(book);
}

// Add similarly structured Delete actions

Finally, update the Startup.cs file to include the necessary services and middleware for Entity Framework Core, and then configure the routes and dependency injection.

By following these steps, you now have a simple ASP.NET MVC application with a basic CRUD operation. Keep exploring and expanding your application, and don't forget to utilize features like Razor Pages, Tag Helpers, and view components to enhance your development experience.

Embarking on your ASP.NET MVC journey, remember that practice makes perfect. Continue building more complex applications, gradually incorporating advanced ASP.NET features and best practices. Happy coding!