How daohainam/lets-learn-aspnet works
Project type and purpose
• This repo is a teaching/learning repository containing multiple small ASP.NET Core applications:
– JwtDemo: MVC site with JWT-based API calls
– MiddlewareDemo: custom middleware pipelines (ClientInfo, HTTPS redirection)
– MyOidcServer + OidcWebClient: a custom OIDC identity server and a protected client app
– MySession: demo of custom session storage via middleware/DI
– SecurityDemo: account management MVC site with pluggable user-storage
– TodoApi: minimal Web API with repository abstractions and MongoDB implementation
– TodoList: classic MVC To-Do List with layered design (Entities, UseCases, Infrastructure, Web UI)
File structure
• Top-level “Projects” folder holds each sample as its own ASP.NET Core project or solution.
• Each project follows the standard ASP.NET Core layout:
– Program.cs → host and configure middleware
– Controllers folder → HTTP endpoints (MVC actions or API controllers)
– Models → view- or data-transfer models
– Views/wwwroot → Razor views and static assets
– Custom folders (Middleware, Repositories, UseCases, Entities) → business logic & data access
• Configuration files (appsettings.json, launchSettings.json) define environment settings.
Key insights from README
• The repo is a course covering ASP.NET MVC, Web API, middleware, session, authentication/authorization, OIDC, testing, Docker/NGINX.
• There is no single database—some samples use in-memory storage, some use MongoDB, some are stateless.
a. Main components (generic template for an ASP.NET Core app):
1. Client (Browser or HTTP client)
2. Reverse Proxy (optional NGINX/Docker)
3. ASP.NET Core Host (Kestrel)
4. Middleware Pipeline (built-in + custom middleware)
5. Routing to Controllers / Endpoints
6. Controllers → call into:
– Business Logic / UseCases
– Session or Token Services
– Repositories (In-memory, MongoDB, JSON file, custom session store)
7. Data stores (In-memory, MongoDB, JSON files)
8. Views + Static Files (wwwroot)
b. Relationships & interactions:
– HTTP request flows: Browser → (NGINX) → Kestrel → Middleware Pipeline
– Pipeline invokes custom middleware (e.g., HTTPS redirect, ClientInfo, session handling)
– Router dispatches to Controller Actions
– Controllers use injected services (UseCases, JwtGenerator, SessionStorage, Repositories)
– Services perform business logic, then read/write to repository → Data store
– Controller returns View or JSON response → back through pipeline → Client
c. Architectural patterns & design principles:
– Layered architecture (Presentation → Application → Domain → Infrastructure)
– Middleware pipeline pattern in ASP.NET Core
– Dependency injection for repositories & services
– Repository pattern with abstractions (e.g., IToDoRepository, IUserRepository)
– Separation of concerns (custom OIDC server vs. client vs. API demos)
– Pluggable storage engines (e.g., MySessionStorageEngine, JsonFileUserRepository, MongoDbToDoRepository)
d. Key technologies & libraries:
– ASP.NET Core MVC & Web API
– Razor Views, static files (wwwroot)
– Custom middleware (classes under Middleware folder)
– JWT (JwtDemo), OIDC (MyOidcServer), session storage (MySession)
– DI container (built into .NET)
– MongoDB driver (in TodoApi)
– Integration testing (XUnit, TestServer)