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 |
|---|---|---|
| 1 | Introduction to ASP.NET Core MVC | 2 hours |
| 2 | C# Fundamentals for MVC | 4 hours |
| 3 | Project Structure and MVC Pattern | 3 hours |
| 4 | Controllers and Actions | 3 hours |
| 5 | Views and Razor Syntax | 4 hours |
| 6 | Models and ViewModels | 3 hours |
| 7 | Forms and Validation | 4 hours |
| 8 | Routing and Navigation | 3 hours |
| 9 | Entity Framework Core | 5 hours |
| 10 | CRUD Application Development | 6 hours |
| 11 | Authentication and Authorization Concepts | 4 hours |
| 12 | Error Handling, Logging, and Security Basics | 3 hours |
| 13 | Publishing and Deployment | 3 hours |
| 14 | Final Project | 8 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 |
|---|---|
| Controllers | Contains controller classes that handle requests |
| Models | Contains data models and business objects |
| Views | Contains Razor .cshtml files |
| wwwroot | Contains static files such as CSS, JavaScript, and images |
| Data | Often 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.
@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 1 | Create a new ASP.NET Core MVC project | Working MVC application |
| Lab 2 | Create controllers and views | Basic navigation |
| Lab 3 | Create models and ViewModels | Structured data handling |
| Lab 4 | Build forms | User input collection |
| Lab 5 | Add validation | Safer forms |
| Lab 6 | Connect Entity Framework Core | Database-backed application |
| Lab 7 | Build CRUD screens | Complete data management |
| Lab 8 | Publish to IIS | Deployable web application |
Assessment Strategy
| Assessment | Weight |
|---|---|
| Weekly practical labs | 30% |
| C# and MVC quiz | 20% |
| CRUD assignment | 20% |
| Final project | 30% |
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