Quick Reference Cards
Card 1: Request Pipeline & Middleware Order
Standard Middleware Pipeline Order
┌─────────────────────────────────────────────────┐
│ HTTP Request │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 1. Exception Handler (Global Error Handling) │
│ app.UseExceptionHandler() │
│ OR app.UseDeveloperExceptionPage() (Dev) │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 2. HSTS (HTTP Strict Transport Security) │
│ app.UseHsts() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 3. HTTPS Redirection │
│ app.UseHttpsRedirection() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 4. Static Files (wwwroot) │
│ app.UseStaticFiles() │
│ ⚡ Short-circuits if file found │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 5. Routing │
│ app.UseRouting() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 6. CORS (Cross-Origin Resource Sharing) │
│ app.UseCors() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 7. Authentication (Who are you?) │
│ app.UseAuthentication() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 8. Authorization (What can you do?) │
│ app.UseAuthorization() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 9. Session (if needed) │
│ app.UseSession() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 10. Custom Middleware │
│ app.UseMyCustomMiddleware() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 11. Response Caching │
│ app.UseResponseCaching() │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ 12. Endpoints (Controllers/Minimal APIs) │
│ app.MapControllers() │
│ app.MapGet("/api/users", ...) │
└──────────────────┬──────────────────────────────┘
│
┌──────────────────▼──────────────────────────────┐
│ HTTP Response │
└──────────────────────────────────────────────────┘Built-in Middleware Quick Reference
Middleware
Method
When to Use
Position
Common Middleware Mistakes
❌ Wrong
✅ Correct
Issue
Minimal Program.cs Template
Request/Response Flow
Key Principles
Card 2: Service Lifetimes Quick Reference
Service Lifetime Types
Registration Methods
Visual Lifetime Comparison
When to Use Which
Service Type
Use Transient
Use Scoped
Use Singleton
Common Service Patterns
Dependency Rules (Captive Dependencies)
Decision Tree
Common Registrations
Tips
Card 3: HTTP Methods & Status Codes
HTTP Methods (Verbs)
Method
Purpose
Body
Idempotent
Safe
Cacheable
HTTP Status Codes
2xx Success
Code
Name
When to Use
Action Result
3xx Redirection
Code
Name
When to Use
Action Result
4xx Client Errors
Code
Name
When to Use
Action Result
5xx Server Errors
Code
Name
When to Use
Action Result
RESTful API Patterns
Complete CRUD Example
Status Code Decision Tree
Common Mistakes
❌ Wrong
✅ Correct
Quick Tips
Card 4: EF Core Quick Reference
DbContext Essentials
Registration & Connection String
CRUD Operations
Common Query Patterns
Migrations Commands
Relationships
Performance Tips
Common Patterns
Card 5: Validation Attributes
Built-in Validation Attributes
Complete Validation Attributes Reference
Attribute
Purpose
Example
Common Regex Patterns
Custom Validation Attribute
FluentValidation Quick Start
Model State Handling
Validation Error Response
Card 6: Authentication & Authorization
Authentication vs Authorization
JWT Authentication Setup
Authorization Attributes
Role-Based Authorization
Claims-Based Authorization
Policy-Based Authorization ⭐
Custom Authorization Requirement
Common Auth Patterns
Cookie Authentication (Alternative to JWT)
Quick Decision Tree
Last updated