Introduction to ASP.NET C# with MVC

A beginner-to-intermediate course for learning C#, ASP.NET Core MVC, Razor views, controllers, models, routing, forms, validation, Entity Framework Core, authentication concepts, and deployment.

Course Summary

This course introduces students to building web applications using ASP.NET Core MVC and C#. It is designed for students, developers, IT trainees, and business application builders who want to create structured web systems using the Model-View-Controller pattern.

C# ASP.NET Core MVC Razor Views Entity Framework Core SQL Server/PostgreSQL

Target Audience

  • Beginners learning web development with C#
  • Developers moving from desktop applications to web applications
  • Students learning ASP.NET Core MVC
  • GIS and land information system developers building web portals
  • Developers building business applications, dashboards, and admin systems

Prerequisites

  • Basic computer skills
  • Basic understanding of HTML and CSS
  • Some programming knowledge is helpful but not required
  • Visual Studio 2022 or later
  • .NET SDK installed

Course Duration

Module Topic Suggested Duration
1Introduction to ASP.NET Core MVC2 hours
2C# Fundamentals for MVC4 hours
3Project Structure and MVC Pattern3 hours
4Controllers and Actions3 hours
5Views and Razor Syntax4 hours
6Models and ViewModels3 hours
7Forms and Validation4 hours
8Routing and Navigation3 hours
9Entity Framework Core5 hours
10CRUD Application Development6 hours
11Authentication and Authorization Concepts4 hours
12Error Handling, Logging, and Security Basics3 hours
13Publishing and Deployment3 hours
14Final Project8 hours

Total Suggested Duration: 55 hours

Module 1: Introduction to ASP.NET Core MVC

Learning Objectives

  • Understand what ASP.NET Core is
  • Understand the MVC design pattern
  • Learn how web requests are handled
  • Create a basic MVC application

Topics

  • What is ASP.NET Core?
  • What is MVC?
  • Model, View, Controller responsibilities
  • Request and response lifecycle
  • Advantages of MVC architecture

Module 2: C# Fundamentals for MVC

Topics

  • Variables and data types
  • Classes and objects
  • Properties and methods
  • Lists and collections
  • LINQ basics
  • Nullable types

Example C# Class

public class Student
{
    public int Id { get; set; }
    public string FullName { get; set; } = string.Empty;
    public string Email { get; set; } = string.Empty;
    public DateTime DateRegistered { get; set; } = DateTime.Now;
}

Module 3: Project Structure and MVC Pattern

Common MVC Folders

Folder Purpose
ControllersContains controller classes that handle requests
ModelsContains data models and business objects
ViewsContains Razor .cshtml files
wwwrootContains static files such as CSS, JavaScript, and images
DataOften contains database context classes

Module 4: Controllers and Actions

Controllers receive requests, execute logic, and return views or data.

Example Controller

using Microsoft.AspNetCore.Mvc;

public class StudentsController : Controller
{
    public IActionResult Index()
    {
        return View();
    }

    public IActionResult Details(int id)
    {
        ViewBag.StudentId = id;
        return View();
    }
}

Module 5: Views and Razor Syntax

Views are Razor .cshtml files that generate HTML. Razor allows C# to be used inside HTML pages.

Important correction: This file does not use an @model directive. If a Razor file uses @model, it must appear at the very beginning of the line with no spaces before it.

Example Razor View

@{
    ViewData["Title"] = "Students";
}

<h1>Students</h1>
<p>This page displays student records.</p>

Module 6: Models and ViewModels

Models represent data. ViewModels are special classes designed to pass only the required data to a view.

Example ViewModel

public class StudentViewModel
{
    public int Id { get; set; }
    public string FullName { get; set; } = string.Empty;
    public string CourseName { get; set; } = string.Empty;
}

Module 7: Forms and Validation

Topics

  • HTML forms
  • POST requests
  • Model binding
  • Data annotations
  • Validation messages
  • Anti-forgery tokens

Example Model with Validation

using System.ComponentModel.DataAnnotations;

public class RegisterStudentModel
{
    [Required]
    public string FullName { get; set; } = string.Empty;

    [Required]
    [EmailAddress]
    public string Email { get; set; } = string.Empty;
}

Module 8: Routing and Navigation

Routing maps incoming URLs to controllers and actions.

Default MVC Route

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

Module 9: Entity Framework Core

Entity Framework Core allows applications to work with databases using C# classes.

Example DbContext

using Microsoft.EntityFrameworkCore;

public class ApplicationDbContext : DbContext
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
    {
    }

    public DbSet<Student> Students { get; set; }
}

Module 10: CRUD Application Development

Students build a complete Create, Read, Update, and Delete application.

CRUD Features

  • Create new records
  • Display records in a table
  • Edit existing records
  • Delete records safely
  • Search and filter records

Module 11: Authentication and Authorization Concepts

Topics

  • User registration
  • Login and logout
  • Password hashing
  • Roles and permissions
  • Protecting controller actions

Example Authorization Attribute

[Authorize]
public IActionResult Dashboard()
{
    return View();
}

Module 12: Error Handling, Logging, and Security Basics

  • Exception handling
  • Logging with ILogger
  • Input validation
  • Cross-site scripting prevention
  • Cross-site request forgery prevention
  • Secure connection strings

Module 13: Publishing and Deployment

Topics

  • Publishing from Visual Studio
  • Deploying to IIS
  • Using appsettings.json
  • Database connection strings
  • Environment settings

Module 14: Final Project

Students build a complete ASP.NET Core MVC application.

Suggested Final Project: Student Registration System

  • Home page
  • Student registration form
  • Student list page
  • Edit student page
  • Delete confirmation page
  • Database storage using Entity Framework Core
  • Basic authentication concept

Alternative Final Project: Land Parcel Administration Portal

  • Parcel registration
  • Owner records
  • Search by parcel number
  • County and locality filtering
  • Basic dashboard

Practical Labs

Lab Description Outcome
Lab 1Create a new ASP.NET Core MVC projectWorking MVC application
Lab 2Create controllers and viewsBasic navigation
Lab 3Create models and ViewModelsStructured data handling
Lab 4Build formsUser input collection
Lab 5Add validationSafer forms
Lab 6Connect Entity Framework CoreDatabase-backed application
Lab 7Build CRUD screensComplete data management
Lab 8Publish to IISDeployable web application

Assessment Strategy

Assessment Weight
Weekly practical labs30%
C# and MVC quiz20%
CRUD assignment20%
Final project30%

Expected Learning Outcomes

By the end of this course, students should be able to:

  • Explain the MVC design pattern
  • Create ASP.NET Core MVC applications
  • Write C# classes for models and ViewModels
  • Create controllers and action methods
  • Build Razor views
  • Create forms with validation
  • Connect an MVC application to a database
  • Build full CRUD functionality
  • Understand authentication and authorization concepts
  • Deploy an ASP.NET Core MVC application

Recommended Tools

  • Visual Studio 2022 or later
  • .NET SDK
  • SQL Server, PostgreSQL, or SQLite
  • Entity Framework Core
  • Git
  • Browser developer tools