Runnable .NET code samples that accompany tutorials published on dotnet-guide.com.
Each sample folder contains a focused implementation of one tutorial topic. The full explanation, design reasoning, production considerations, and step-by-step walkthrough remain on the corresponding DOTNET GUIDE tutorial page.
| Sample | What it demonstrates | Full tutorial |
|---|---|---|
dotnet-ai/provider-agnostic-chat-gateway |
One HTTP chat endpoint using Ollama and optional OpenAI providers through Microsoft.Extensions.AI.IChatClient |
Build a switchable multi-provider AI gateway with IChatClient |
dotnet-ai/hybrid-search-ef-core-pgvector |
Minimal Reciprocal Rank Fusion demo combining pre-ranked keyword and vector results | Hybrid Search in .NET with EF Core 10 and pgvector |
dotnet-aspire/orchestrate-distributed-system |
Minimal Aspire AppHost coordinating a web project and API with service discovery and startup ordering | Aspire in .NET: Orchestrate, Run, and Deploy a Distributed System from One App Host |
software-architecture/architecture-testing-dotnet |
Minimal NetArchTest.eNhancedEdition rule that prevents Domain from depending on outer layers | Architecture Testing in .NET: Enforce Layer and Module Boundaries with NetArchTest and ArchUnitNET |
distributed-systems/transactional-outbox-ef-core |
Minimal EF Core and SQLite demonstration that saves business state and an outbox message atomically, then publishes it through a one-shot relay | Transactional Outbox Pattern in .NET with EF Core (.NET 10): Fix the Dual-Write Problem |
aspnet-core/api-security-in-practice |
Minimal JWT bearer authentication, note ownership enforcement, and rate limiting for an ASP.NET Core API | ASP.NET Core 8 API Security: JWT Authentication, CSRF Protection & Rate Limiting |
aspnet-core/passkey-first-identity |
Minimal .NET 10 Identity sample for passkey enrollment, username-first passkey sign-in, antiforgery protection, and stored credential listing | Passkeys in ASP.NET Core Identity (.NET 10): Build a Passwordless-First Web App with WebAuthn |
aspnet-core/build-web-api-dotnet-8 |
Minimal .NET 10 Todo API demonstrating route groups, dependency injection, CRUD status codes, validation, middleware, and integration testing | ASP.NET Core Fundamentals: Build Web APIs on .NET 8 |
- Common Microsoft.Extensions.AI mistakes
- Vector search in .NET: Common mistakes
- NetArchTest, ArchUnitNET, and Roslyn analyzers
- Transactional outbox relay: Common mistakes
- ASP.NET Core API security checklist
- Click the green Code button.
- Choose Download ZIP.
- Extract the downloaded archive.
- Open PowerShell in the required sample folder.
- Follow that folder's
README.md.
cd dotnet-ai\provider-agnostic-chat-gateway
dotnet restore
dotnet run --urls http://localhost:5123cd dotnet-ai\hybrid-search-ef-core-pgvector
dotnet restore
dotnet runtutorials/
|-- dotnet-ai/
| |-- provider-agnostic-chat-gateway/
| | |-- ChatGatewayMinimal.csproj
| | |-- Program.cs
| | `-- README.md
| `-- hybrid-search-ef-core-pgvector/
| |-- HybridSearchMinimal.csproj
| |-- Program.cs
| `-- README.md
|-- dotnet-aspire/
| `-- orchestrate-distributed-system/
| |-- AspireOrchestrationMinimal.slnx
| |-- README.md
| |-- AspireOrchestrationMinimal.AppHost/
| | |-- AppHost.cs
| | `-- AspireOrchestrationMinimal.AppHost.csproj
| |-- AspireOrchestrationMinimal.Api/
| | |-- Program.cs
| | `-- AspireOrchestrationMinimal.Api.csproj
| `-- AspireOrchestrationMinimal.Web/
| |-- Program.cs
| `-- AspireOrchestrationMinimal.Web.csproj
|-- software-architecture/
| `-- architecture-testing-dotnet/
| |-- ArchitectureGuardMinimal.slnx
| |-- README.md
| |-- src/
| | |-- ArchitectureGuard.Domain/
| | | |-- ArchitectureGuard.Domain.csproj
| | | |-- DomainAssemblyMarker.cs
| | | `-- Order.cs
| | |-- ArchitectureGuard.Application/
| | | |-- ArchitectureGuard.Application.csproj
| | | |-- ApplicationAssemblyMarker.cs
| | | `-- GetOrderSummary.cs
| | `-- ArchitectureGuard.Infrastructure/
| | |-- ArchitectureGuard.Infrastructure.csproj
| | |-- InfrastructureAssemblyMarker.cs
| | `-- InMemoryOrderRepository.cs
| `-- tests/
| `-- ArchitectureGuard.ArchitectureTests/
| |-- ArchitectureGuard.ArchitectureTests.csproj
| `-- LayerRules.cs
|-- distributed-systems/
| `-- transactional-outbox-ef-core/
| |-- TransactionalOutboxMinimal.slnx
| |-- README.md
| |-- src/
| | `-- TransactionalOutboxMinimal/
| | |-- TransactionalOutboxMinimal.csproj
| | |-- Program.cs
| | |-- Data/
| | | `-- OrdersDbContext.cs
| | |-- Domain/
| | | `-- Order.cs
| | |-- Messaging/
| | | |-- OrderPlaced.cs
| | | |-- OutboxMessage.cs
| | | |-- IPublisher.cs
| | | |-- InMemoryPublisher.cs
| | | `-- OutboxRelay.cs
| | `-- Services/
| | `-- OrderService.cs
| `-- tests/
| `-- TransactionalOutboxMinimal.Tests/
| |-- TransactionalOutboxMinimal.Tests.csproj
| `-- OutboxFlowTests.cs
|-- aspnet-core/
| |-- api-security-in-practice/
| | |-- ApiSecurityMinimal.slnx
| | |-- README.md
| | |-- src/
| | | `-- ApiSecurityMinimal/
| | | |-- ApiSecurityMinimal.csproj
| | | |-- Program.cs
| | | |-- Models.cs
| | | |-- DemoStore.cs
| | | |-- JwtTokenService.cs
| | | `-- appsettings.json
| | `-- tests/
| | `-- ApiSecurityMinimal.Tests/
| | |-- ApiSecurityMinimal.Tests.csproj
| | `-- ApiSecurityTests.cs
| |-- passkey-first-identity/
| | |-- PasskeyIdentityMinimal.slnx
| | |-- README.md
| | |-- src/
| | | `-- PasskeyIdentityMinimal/
| | | |-- PasskeyIdentityMinimal.csproj
| | | |-- Program.cs
| | | |-- appsettings.json
| | | |-- Data/
| | | | |-- ApplicationDbContext.cs
| | | | `-- ApplicationUser.cs
| | | |-- Endpoints/
| | | | |-- AntiforgeryEndpointExtensions.cs
| | | | `-- PasskeyEndpoints.cs
| | | `-- wwwroot/
| | | |-- index.html
| | | `-- passkeys.js
| | `-- tests/
| | `-- PasskeyIdentityMinimal.Tests/
| | |-- PasskeyIdentityMinimal.Tests.csproj
| | |-- PasskeyEndpointTests.cs
| | `-- PasskeyIdentityFactory.cs
| `-- build-web-api-dotnet-8/
| |-- TodoApiMinimal.slnx
| |-- README.md
| |-- src/
| | `-- TodoApiMinimal/
| | |-- TodoApiMinimal.csproj
| | `-- Program.cs
| `-- tests/
| `-- TodoApiMinimal.Tests/
| |-- TodoApiMinimal.Tests.csproj
| `-- TodoApiTests.cs
|-- .github/
| `-- workflows/
| `-- build-samples.yml
|-- .gitignore
|-- LICENSE
`-- README.md
This repository contains educational code samples only.
It does not contain:
- the DOTNET GUIDE website source code
- production credentials
- analytics configuration
- private deployment paths
- API keys
- complete production applications
The sample folders are intentionally smaller than their corresponding tutorials. Advanced setup, design discussion, database configuration, production hardening, and extended implementation guidance remain on the DOTNET GUIDE website.
Each sample identifies:
- its target .NET version
- its required NuGet package versions, when applicable
- its local model, database, or service requirements
- its last-reviewed date
- the commands needed to restore, build, and run it
Some lightweight samples may have no external package dependencies or service requirements.
Libraries and platforms related to AI, authentication, Aspire, distributed systems, databases, and vector search may change quickly. Check the sample's review date and current official documentation before adapting it to a newer SDK or package version.
dotnet-guide.com is an independent educational website. It is not affiliated with, endorsed by, or connected to Microsoft Corporation.
Microsoft, .NET, C#, ASP.NET Core, Azure, and related names may be trademarks of Microsoft Corporation. Other product names belong to their respective owners.
Found a compile error or outdated API?
Open an issue and include:
- the sample path
- your .NET SDK version
- the command you ran
- the complete error message
- your operating system
Small and focused pull requests are also welcome.
Repository-owned sample code is available under the MIT License.
Third-party libraries remain subject to their own licenses.