# How ASP.NET Core Samples Are Structured in the dotnet/aspnetcore Repository

> Discover how ASP.NET Core samples are organized in the dotnet/aspnetcore repository. Learn about their self-contained project structure for independent execution with dotnet run.

- Repository: [.NET Platform/aspnetcore](https://github.com/dotnet/aspnetcore)
- Tags: internals
- Published: 2026-08-01

---

**ASP.NET Core samples are organized under `src/<Component>/samples/` as self-contained projects, each containing a project file, entry point, and configuration files that can be executed independently with `dotnet run`.**

The dotnet/aspnetcore repository houses hundreds of runnable sample applications that demonstrate specific framework features. These samples follow a strict organizational hierarchy that maps directly to ASP.NET Core component areas, enabling developers to quickly locate working implementations of SignalR, Middleware, Identity, and other capabilities.

## Directory Structure and Organization

All samples reside within the `src/` folder and follow a consistent three-level hierarchy:

```

src/
 └─ <Component>/
     └─ samples/
         └─ <SampleName>/
             ├─ *.csproj / *.fsproj
             ├─ Program.cs | Program.fs
             ├─ Startup.cs (optional)
             ├─ appsettings*.json
             ├─ launchSettings.json
             └─ wwwroot/ (if applicable)

```

- **`<Component>`** represents the ASP.NET Core area being demonstrated, such as `SignalR`, `Middleware/WebSockets`, `Identity`, `Http`, or `Antiforgery`.
- **`<SampleName>`** is a self-contained directory containing all files necessary to build and execute the project.
- Each sample is fully isolated, meaning you can navigate to any sample folder and execute `dotnet run` without additional dependencies.

Most components organize samples under `src/<Component>/samples/<SampleName>/`, though some simpler components like `Middleware/Session` place sample files directly under `src/Middleware/Session/samples/` without an additional subdirectory.

## Sample Project Components

### Project Files and Entry Points

Every sample includes a project file (`*.csproj` for C# or `*.fsproj` for F#) that defines the target framework and package references. The entry point is typically [`Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/Program.cs) (or `Program.fs`), which configures the minimal hosting model:

```csharp
// Example from src/SignalR/samples/WebSocketSample/Program.cs
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// Middleware configuration
app.Run();

```

Legacy samples may include a separate [`Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/Startup.cs) file containing the `ConfigureServices` and `Configure` methods, as seen in [`src/SignalR/samples/SocialWeather/Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/samples/SocialWeather/Startup.cs).

### Configuration and Static Assets

Samples include [`appsettings.json`](https://github.com/dotnet/aspnetcore/blob/main/appsettings.json) for default configuration settings such as logging levels and Kestrel endpoints. Debug-specific settings reside in [`launchSettings.json`](https://github.com/dotnet/aspnetcore/blob/main/launchSettings.json). Samples serving web content include a `wwwroot/` folder containing static HTML, CSS, and JavaScript files, such as [`src/Middleware/WebSockets/samples/EchoApp/wwwroot/index.html`](https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/WebSockets/samples/EchoApp/wwwroot/index.html).

## How to Run the Samples

Each sample is designed to execute independently. Navigate to the specific sample directory and use the .NET CLI:

```bash

# Example: Running the SignalR WebSocketSample

cd src/SignalR/samples/WebSocketSample
dotnet run

```

```bash

# Example: Running the Middleware StaticFileSample

cd src/Middleware/StaticFiles/samples/StaticFileSample
dotnet run

```

The project file automatically references the necessary ASP.NET Core libraries from the repository, eliminating the need for manual package restoration in most cases.

## Real-World Examples by Component

The repository contains diverse samples demonstrating specific framework capabilities:

- **SignalR**: `WebSocketSample` ([`src/SignalR/samples/WebSocketSample/Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/samples/WebSocketSample/Program.cs)) demonstrates WebSocket configurations, while `SocialWeather` ([`src/SignalR/samples/SocialWeather/Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/samples/SocialWeather/Startup.cs)) shows hub implementations with separate startup classes.

- **Middleware**: The `EchoApp` ([`src/Middleware/WebSockets/samples/EchoApp/Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/WebSockets/samples/EchoApp/Program.cs)) illustrates WebSocket middleware usage, and `StaticFileSample` ([`src/Middleware/StaticFiles/samples/StaticFileSample/Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/StaticFiles/samples/StaticFileSample/Startup.cs)) demonstrates static file serving configurations.

- **Identity**: `IdentitySample.PasskeyUI` ([`src/Identity/samples/IdentitySample.PasskeyUI/Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/Identity/samples/IdentitySample.PasskeyUI/Program.cs)) contains Razor components and authentication flows.

- **HTTP & Minimal APIs**: `MinimalSample` ([`src/Http/samples/MinimalSample/Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/Http/samples/MinimalSample/Program.cs)) and `MinimalFormSample` ([`src/Antiforgery/samples/MinimalFormSample/Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/Antiforgery/samples/MinimalFormSample/Program.cs)) showcase modern minimal API patterns.

- **HTTP Logging**: `Logging.W3C.Sample` ([`src/Middleware/HttpLogging/samples/Logging.W3C.Sample/Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/HttpLogging/samples/Logging.W3C.Sample/Program.cs)) demonstrates W3C logger implementations.

## Summary

- ASP.NET Core samples follow the `src/<Component>/samples/<SampleName>/` hierarchy.
- Each sample is a **self-contained project** with its own `.csproj`, entry point, and configuration files.
- Entry points are typically [`Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/Program.cs) (minimal hosting) or [`Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/Startup.cs) (legacy configuration).
- Samples can be executed immediately using `dotnet run` from their respective directories.
- Static assets are isolated within `wwwroot/` folders inside individual sample directories.

## Frequently Asked Questions

### Where are ASP.NET Core samples located in the repository?

Samples are located under the `src/` directory, organized by component area. The full path pattern is `src/<Component>/samples/<SampleName>/`, such as `src/SignalR/samples/WebSocketSample/` or `src/Identity/samples/IdentitySample.PasskeyUI/`.

### Can I run ASP.NET Core samples directly from the repository?

Yes. Each sample is a standalone project that builds against the repository's source code. Navigate to any sample folder (for example, `src/Http/samples/MinimalSample/`) and execute `dotnet run` to launch the application without additional setup.

### What is the difference between Program.cs and Startup.cs in the samples?

[`Program.cs`](https://github.com/dotnet/aspnetcore/blob/main/Program.cs) is the modern entry point used in minimal hosting models, containing `WebApplication.CreateBuilder()` and middleware configuration. [`Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/Startup.cs) appears in older samples and separates service configuration (`ConfigureServices`) from the request pipeline (`Configure`), as seen in [`src/SignalR/samples/SocialWeather/Startup.cs`](https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/samples/SocialWeather/Startup.cs).

### Are there F# samples available in the repository?

Yes. While C# dominates, the repository structure supports F# samples using `*.fsproj` project files and `Program.fs` entry points. The organizational structure remains identical regardless of language.