A comprehensive learning repository containing 20 focused modules that demonstrate core ASP.NET Core concepts through practical, runnable examples. Each module is a complete, self-contained project with detailed comments and interactive testing capabilities.
- .NET 8 SDK or later (Download)
- IDE (choose one):
- Visual Studio 2022
- VS Code with C# Dev Kit extension
- JetBrains Rider
Option 1: Visual Studio 2022
- Open
ASPNETCore-Essentials.sln - Right-click any project in Solution Explorer
- Select "Set as Startup Project"
- Press
F5or click "Run"
Option 2: VS Code
- Open the repository folder
- Install C# Dev Kit extension
- Open any module folder (e.g.,
src/01-MinimalApiBasics) - Press
F5or use the Run menu
Option 3: Command Line
# Navigate to any module
cd src/01-MinimalApiBasics
# Run the project
dotnet run
# The app will start and display URLs:
# https://localhost:5001
# http://localhost:5000Most modules include Swagger UI for interactive testing:
- Run the module
- Navigate to
https://localhost:{port}/swagger - Expand endpoints and click "Try it out"
- Fill in parameters and click "Execute"
Each module is a standalone project demonstrating specific ASP.NET Core concepts. Click the links to explore the code.
Hello world, route parameters, query strings, request binding, response types, CRUD operations, async endpoints, HTTP methods
- 15+ endpoint examples
- Complete CRUD operations
- Data validation
- Swagger documentation
Custom middleware, request pipeline, endpoint routing, route constraints, middleware ordering
- Custom middleware components
- Pipeline visualization
- Route constraint examples
appsettings.json, environment variables, configuration providers, ILogger, structured logging
- Multiple configuration sources
- Structured logging patterns
- Log levels and filtering
Service lifetimes (Singleton, Scoped, Transient), options pattern, typed clients, service registration
- Service lifetime demonstrations
- Options pattern implementation
- Configuration binding
Controllers, views, layouts, partial views, tag helpers, view components, model binding
- Complete MVC pattern
- Razor view engine
- Tag helpers and view components
Page models, page handlers, TempData, validation, forms, routing
- Page-based architecture
- Form handling
- Model validation
RESTful APIs, DTOs, model validation, API versioning, Swagger/OpenAPI documentation
- RESTful design patterns
- DTO mapping
- API versioning strategies
DbContext, relationships (one-to-many), LINQ queries, filtering, pagination, aggregations, seeding data, SQLite database
- Complete relational model
- Advanced queries
- Eager loading
- Data seeding
Cookie authentication, JWT bearer tokens, identity basics, authorization policies, claims
- Cookie-based auth
- JWT token generation
- Authorization policies
Action filters, exception filters, result filters, custom model binders, validation attributes
- Custom filters
- Model binding customization
- Validation patterns
In-memory caching, response caching, distributed cache patterns, response compression (Gzip, Brotli)
- Memory cache
- Response caching
- Compression middleware
IHostedService, BackgroundService, timed background tasks, queued work items, graceful shutdown
- Hosted services
- Background task patterns
- Graceful shutdown handling
Health check endpoints, custom health checks, database health checks, OpenTelemetry integration, distributed tracing, metrics
- Multiple health endpoints
- Custom health checks
- OpenTelemetry integration
- Distributed tracing
WebSocket connections, hubs, real-time messaging, broadcasting, groups, streaming data, JavaScript client
- Chat hub with private messages
- Notification broadcasting
- Stock ticker streaming
- Interactive HTML client
Protocol Buffers, unary RPC, server streaming, client streaming, bidirectional streaming, gRPC reflection, CRUD operations
- All 4 RPC types
- Protocol Buffers definitions
- gRPC reflection
- Complete CRUD service
Fixed window, sliding window, token bucket, concurrency limiters, per-IP limiting, custom rate limit policies
- 6 rate limiting strategies
- Custom rejection handlers
- Interactive testing interface
Cross-Origin Resource Sharing policies, security headers (CSP, HSTS, X-Frame-Options), origin validation
- Multiple CORS policies
- Comprehensive security headers
- Clickjacking protection
- XSS protection
Single/multiple file uploads, chunked uploads for large files, file streaming, progress tracking, content-type detection
- Single/multiple uploads
- Chunked upload for large files
- Streaming downloads
- Progress tracking
Global exception handling, RFC 7807 Problem Details, custom exceptions, validation errors, status code pages
- RFC 7807 implementation
- Global exception handler
- Custom exception types
- Standardized error responses
Unit tests with xUnit, integration tests with WebApplicationFactory, mocking with NSubstitute, FluentAssertions, test patterns (AAA), repository tests, service tests, API tests
- 23 unit tests
- 13 integration tests
- Mocking with NSubstitute
- FluentAssertions
- AAA pattern
Start with modules 1-6 to understand ASP.NET Core fundamentals and web UI development.
Week 1: Core Fundamentals
- Day 1-2: Module 01 - Minimal APIs
- Understand endpoints, routing, request/response
- Practice: Create your own API endpoints
- Day 3-4: Module 02 - Middleware
- Learn request pipeline
- Practice: Create custom middleware
- Day 5: Module 03 - Configuration
- Configuration sources
- Practice: Add custom configuration
- Day 6-7: Module 04 - Dependency Injection
- Service lifetimes
- Practice: Create and inject your own services
Week 2: Web Development
- Day 1-3: Module 05 - MVC
- Controllers, views, models
- Practice: Build a simple CRUD UI
- Day 4-5: Module 06 - Razor Pages
- Page-based architecture
- Practice: Create form-based pages
- Day 6-7: Module 07 - Web API
- RESTful API design
- Practice: Build a complete API
Progress through modules 7-12 to learn API development, data access, authentication, and performance optimization.
Week 3: Data & Security
- Day 1-3: Module 08 - Entity Framework
- Database operations, relationships
- Practice: Design your own data model
- Day 4-5: Module 09 - Authentication
- Cookie and JWT auth
- Practice: Secure your API
- Day 6-7: Module 10 - Filters & Validation
- Request/response pipeline customization
- Practice: Create custom filters
Week 4: Performance & Advanced
- Day 1-2: Module 11 - Caching
- Memory and response caching
- Practice: Add caching to your API
- Day 3: Module 12 - Background Services
- Long-running tasks
- Practice: Create a scheduled task
- Day 4: Module 13 - Health Checks
- Monitoring and observability
- Practice: Add health checks to your app
- Day 5: Module 14 - SignalR
- Real-time communication
- Practice: Build a simple chat
- Day 6: Module 15 - gRPC
- High-performance RPC
- Practice: Create a gRPC service
- Day 7: Review and build a project combining multiple concepts
Explore modules 13-20 for real-time communication, gRPC, security, error handling, and testing strategies.
Week 5: Security & Production
- Day 1: Module 16 - Rate Limiting
- API throttling
- Practice: Add rate limits to your API
- Day 2: Module 17 - CORS & Security
- Cross-origin security
- Practice: Secure your frontend-backend communication
- Day 3: Module 18 - File Upload
- File handling
- Practice: Add file upload to your app
- Day 4: Module 19 - Error Handling
- Proper error responses
- Practice: Implement global error handling
- Day 5-7: Module 20 - Testing
- Unit and integration testing
- Practice: Write tests for your code
# From repository root
dotnet test
# With detailed output
dotnet test --verbosity normal# Navigate to the testing module
cd src/20-Testing
# Run all tests (unit + integration)
dotnet test
# Watch mode (auto-run on changes)
dotnet watch testTest Summary:
- Unit Tests: 23 tests (ProductService, ProductRepository)
- Integration Tests: 13 tests (Full API testing)
- Total: 36 comprehensive tests
Each module runs on a unique port to avoid conflicts when running multiple modules:
- Run the module:
cd src/14-SignalRRealtime && dotnet run - Open
https://localhost:51140in browser - Use the interactive HTML client
- Open multiple browser tabs to test real-time features
Install grpcurl from https://github.com/fullstorydev/grpcurl
# Run the module
cd src/15-GrpcServices
dotnet run
# In another terminal, test with grpcurl:
# List services
grpcurl -plaintext localhost:51152 list
# Call unary RPC
grpcurl -plaintext -d '{"name": "World"}' localhost:51152 greeter.Greeter/SayHello
# List products
grpcurl -plaintext localhost:51152 products.ProductService/GetAllProductsThe SQLite database is created at src/08-EfCoreSqlite/store.db
# View database with VS Code SQLite extension
# Or use DB Browser for SQLite
# To reset database:
cd src/08-EfCoreSqlite
rm store.db
dotnet run # Database will be recreated with seed data- Run the module:
cd src/18-FileUploadDownload && dotnet run - Open
https://localhost:51180in browser - Use the interactive HTML interface
- Uploaded files are stored in
src/18-FileUploadDownload/uploads/
- ASP.NET Core 8.0 - Web framework
- Entity Framework Core 8.0 - ORM for data access
- SQLite - Embedded database (no external database required)
- SignalR - WebSocket-based real-time communication
- gRPC - High-performance RPC framework
- Protocol Buffers - Efficient serialization
- OpenTelemetry - Distributed tracing and metrics
- Health Checks - Application health monitoring
- Structured Logging - ILogger with structured data
- xUnit - Test framework
- NSubstitute - Mocking library
- FluentAssertions - Fluent assertion library
- WebApplicationFactory - Integration testing
- Rate Limiting - Built-in ASP.NET Core rate limiting
- CORS - Cross-origin resource sharing
- Response Compression - Gzip and Brotli compression
- Response Caching - HTTP caching
If you get a port conflict error:
- Edit
Properties/launchSettings.jsonin the module - Change the port numbers
- Save and run again
# Trust the development certificate
dotnet dev-certs https --trust# From repository root
dotnet restore
# Or for specific project
cd src/01-MinimalApiBasics
dotnet restore# Clean and rebuild
dotnet clean
dotnet build# Delete the database and restart
cd src/08-EfCoreSqlite
rm store.db
dotnet run
# Database will be recreated with seed dataβ
Minimal APIs and traditional MVC patterns
β
Dependency injection and service lifetimes
β
Configuration and logging best practices
β
Entity Framework Core with relationships
β
Authentication and authorization
β
Real-time communication with SignalR
β
High-performance RPC with gRPC
β
Rate limiting and security headers
β
Error handling and problem details
β
Comprehensive testing strategies
β
Background services and hosted services
β
Health checks and observability
β
File upload/download with streaming
β
CORS and web security
β
Caching and compression
- Read the code comments - Each module has detailed explanations
- Experiment - Modify the code and see what happens
- Use the debugger - Set breakpoints and step through code
- Check the logs - Console output shows what's happening
- Test everything - Use Swagger, browser, or Postman
- Build projects - Combine concepts from multiple modules
- Write tests - Practice TDD with Module 20 examples
- Postman - API testing
- grpcurl - gRPC testing
- DB Browser for SQLite - Database viewer
- C# Dev Kit - C# development support
- REST Client - Test HTTP requests
- SQLite Viewer - View SQLite databases
- Thunder Client - API testing
- Total Modules: 20
- Total Test Projects: 1 (unified in Module 20)
- Total Tests: 36 (23 unit + 13 integration)
- Lines of Code: ~3,500+ across all modules
- .NET Version: 8.0
- Cross-platform: Windows, macOS, Linux
This is a learning repository. Feel free to:
- Fork and experiment
- Suggest improvements via issues
- Share your learning projects built with these concepts
MIT License - feel free to use this repository for learning and teaching purposes.
After completing these modules, you'll be ready to:
- Build production applications with ASP.NET Core
- Design RESTful APIs following best practices
- Implement real-time features with SignalR
- Create high-performance services with gRPC
- Secure your applications with proper authentication and authorization
- Monitor and observe your applications in production
- Write comprehensive tests for your code
- Handle errors gracefully with standardized responses
Happy Learning! π