This guide helps a coding agent work efficiently with the practical-aspnetcore repository from the very first interaction.
A large, community-driven collection of practical ASP.NET Core code samples organized by topic. Each sample is intentionally small and focused on demonstrating one concept clearly. The repository is used as a learning resource for developers at all levels.
| Item | Value |
|---|---|
| Runtime | .NET 10 (RC – see global.json) |
| SDK rollForward | major with allowPrerelease: true |
| Web SDK | Microsoft.NET.Sdk.Web |
| Language version | preview (<LangVersion>preview</LangVersion>) |
| Implicit usings | Enabled (<ImplicitUsings>true</ImplicitUsings>) |
| Target framework | net10.0 |
The global.json at the repository root pins the SDK version. Any newer major SDK will also work because rollForward is set to major.
practical-aspnetcore/
├── projects/ # All sample projects live here
│ ├── minimal-api/ # One directory per topic category
│ │ ├── README.md # Index of samples in this category
│ │ ├── build.bat # Optional batch helper
│ │ ├── hello-world/ # One sub-directory per sample
│ │ │ ├── Program.cs # ALL application code goes here
│ │ │ ├── README.md # Description of this sample
│ │ │ └── hello-world.csproj
│ │ └── ...
│ ├── mvc/
│ ├── blazor-wasm/
│ └── ... # 60+ topic categories
├── exercises/ # Learning exercises (separate from samples)
├── scripts/ # Utility scripts (e.g., upgrade-to-net10.ps1)
├── .github/
│ └── FUNDING.yml # GitHub Sponsors config – no CI workflows
├── global.json # SDK version pinning
├── README.md # Main index of all samples (update when adding)
├── CONTRIBUTING.md # Contribution guidelines (read before adding samples)
├── CODE_OF_CONDUCT.md
└── skills-checklist.md # WIP skills checklist
cd projects/<category>/<sample-name>
dotnet watch runOpen http://localhost:5000 in a browser (or the port shown in the terminal).
There is no solution file and no global build command. Every sample is an independent project that is built and run individually.
Follow these steps every time a new sample is created:
projects/<category-name>/<sample-name>/
Use lowercase kebab-case for both the category name and the sample name.
Name the file <sample-name>.csproj. Use this minimal template:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>true</ImplicitUsings>
<LangVersion>preview</LangVersion>
</PropertyGroup>
</Project>Add <PackageReference> entries inside <ItemGroup> only if the sample requires NuGet packages.
All application code must live in Program.cs. This is the most important convention in this repository. Do not create additional .cs files, controllers, or class files unless it is absolutely impossible to demonstrate the concept in a single file (e.g., a Razor Pages .cshtml + code-behind pair).
Typical structure:
// using statements if not covered by implicit usings
var builder = WebApplication.CreateBuilder(args);
// Register services
var app = builder.Build();
// Configure middleware / map routes
app.Run();For the simplest samples WebApplication.Create() is enough (no explicit builder needed):
WebApplication app = WebApplication.Create();
app.Run(async context =>
{
await context.Response.WriteAsync("Hello world");
});
await app.RunAsync();Keep it concise. Include:
- A one-sentence description of what the sample demonstrates.
- Any notable code snippets if useful for comprehension.
- Links to relevant official documentation when helpful.
Add a line for the new sample to the category-level README.md (e.g., projects/minimal-api/README.md).
- Find the relevant section in the table and increment the sample count.
- Add a bullet point describing the sample in the appropriate section further down the file.
- All code in
Program.cs– makes it easy to read online without chasing types across files. - Keep samples small and specific – one concept per sample.
- No sample is too small – if it shows one useful thing, it belongs.
- Update the README and increment the sample count when adding a new sample.
- SDK: Always
Microsoft.NET.Sdk.Web - TargetFramework:
net10.0 - ImplicitUsings:
true(soMicrosoft.AspNetCore.*and other common namespaces are available without explicitusingdirectives) - LangVersion:
preview - No
<Nullable>enable</Nullable>– samples typically omit this for brevity - Project file is named after the sample directory (e.g.,
hello-world.csprojinhello-world/)
There are no GitHub Actions workflows in this repository. The .github/ directory contains only FUNDING.yml. Validation is done manually by running each sample locally with dotnet watch run.
| Issue | Workaround |
|---|---|
| SDK version mismatch | global.json has rollForward: major so any .NET 10+ SDK works. If you only have .NET 8/9, some samples targeting net10.0 won't build. |
allowPrerelease: true required |
The SDK version is a release-candidate. Ensure your local SDK installation includes preview/RC versions. |
| No solution file | There is no .sln file. Load individual .csproj files in your IDE or run dotnet watch run directly inside the sample directory. |
| Samples reference older APIs | A few older samples still use IHostBuilder patterns. New samples should use the modern WebApplication / WebApplicationBuilder pattern. |
| Implicit usings | Many using statements (e.g., Microsoft.AspNetCore.Builder, Microsoft.AspNetCore.Http) are provided by implicit usings and should not need to be explicitly listed in new samples, though older samples may still include them. |
| Goal | Sample location |
|---|---|
| Simplest possible web app | projects/minimal-api/hello-world/ |
| Using builder pattern | projects/minimal-hosting/ |
| Razor Pages | projects/razor-pages/ |
| MVC controllers | projects/mvc/ |
| gRPC | projects/grpc/ |
| Blazor WASM | projects/blazor-wasm/ |
| Blazor SSR | projects/blazor-ssr/ |
| HTMX integration | projects/htmx/ |
| Generic Host (non-web) | projects/generic-host/ |
| Dependency Injection | projects/dependency-injection/ |
- Create
projects/<category>/<sample-name>/directory - Add
<sample-name>.csprojwithnet10.0target - Put ALL code in
Program.cs - Add
README.mddescribing the sample - Update
projects/<category>/README.md - Increment count and add bullet in root
README.md - Verify with
dotnet watch runinside the sample directory