Running the Application

Both templates can run two ways: through the .NET Aspire host (recommended, needs Docker), or by running the Web project directly.

dotnet run --project src/Your.ProjectName.AspireHost

Or set the AspireHost project as the startup project in Visual Studio or Rider and press F5. aspire run from the solution folder works too (in the full template, aspire.config.json points it at the app host).

The Aspire host starts:

ResourceWhat it is
sqlserverA SQL Server container with a persistent lifetime, so data survives restarts
cleanarchitecture / AppDbThe application database (full / minimal template), created automatically
papercutA Papercut SMTP container listening on port 25, with a web UI at http://localhost:37408 to view sent email
webYour Web project, with the database connection string injected and WaitFor dependencies on the containers

The console prints the Aspire dashboard URL, including a login token. The dashboard shows each resource’s logs, traces, and metrics (the Web project exports telemetry through the ServiceDefaults project).

Starting with Aspire 17, a C# app host gets the orchestrator (DCP) and the dashboard from the Aspire CLI bundle, and dotnet run and F5 hand off to the CLI. Install the Aspire CLI at the same version as the app host’s Aspire.Hosting.AppHost package (17.0.0), or run aspire update --self to update an older one. An older CLI fails with “The –apphost option specified a project that does not exist.”

If you don’t want a global CLI, set <AspireCliInvocationMode>DnxPinned</AspireCliInvocationMode> in the app host’s .csproj (or pass -p:AspireCliInvocationMode=DnxPinned to dotnet run). The app host then runs the matching Aspire.Cli package through dnx, which ships with the .NET 10 SDK and later.

To reset the database, stop the app, delete the sqlserver container (from the dashboard or with docker rm), and start again.

Option 2: run the Web project directly

dotnet run --project src/Your.ProjectName.Web

No Docker required, but you need a database the app can reach.

How the database is chosen

Full template. AddInfrastructureServices() in Infrastructure picks the provider at startup, in this order:

OrderConditionProviderConnection string
1ConnectionStrings:cleanarchitecture is set (Aspire provides this)SQL ServerProvided by Aspire
2Running on Windows, or the USE_SQL_SERVER environment variable is true, and ConnectionStrings:DefaultConnection is setSQL ServerDefaultConnection (LocalDB by default)
3OtherwiseSQLiteSqliteConnection (Data Source=database.sqlite)

So on Windows the Web project uses SQL Server LocalDB, which Visual Studio installs. On macOS and Linux it uses a local SQLite file. To use a different SQL Server, change DefaultConnection in appsettings.json (or override it with the ConnectionStrings__DefaultConnection environment variable) and set USE_SQL_SERVER=true on non-Windows machines.

Minimal template. It always uses SQL Server, with the AppDb connection string. It defaults to LocalDB in appsettings.json, and Aspire overrides it.

Migrations and seed data at startup

  • Full template: in the Development environment, or when Database:ApplyMigrationsOnStartup is true, startup applies EF Core migrations (SQL Server) or calls EnsureCreated (SQLite), then seeds sample contributors if the table is empty. Seeding errors are logged but don’t stop the app.
  • Minimal template: startup always applies pending migrations, then seeds sample products if there are none.

See Data & Migrations to create migrations or switch providers.

URLs

The https launch profile is used by default:

Full templateMinimal template
API base URLhttps://localhost:57679https://localhost:57379
Scalar API reference (Development)/scalar/scalar
Swagger UI (Development)/swagger/swagger
OpenAPI document (Development)/openapi/v1.json/openapi/v1.json
Health checks (Development)/health and /alive/health and /alive
Registered services list (Development)/listservices/listservices

/listservices comes from Ardalis.ListStartupServices and lists every service registered in the DI container, which is handy for debugging registrations. Choose your own path (or remove it) before you deploy anything sensitive.

Each Web project includes an api.http file with sample requests you can send from Visual Studio, Rider, or VS Code (with the REST Client extension).

Email

Development uses MimeKitEmailSender, which sends through the SMTP server configured in the Mailserver section of appsettings.json (localhost:25). Under Aspire, that’s the Papercut container, and you can view the messages at http://localhost:37408. In the full template, renaming a contributor sends an email.

If you run the Web project without Aspire and have no SMTP server on port 25, register FakeEmailSender instead (it just logs), in Configurations/ServiceConfigs.cs:

// services.AddScoped<IEmailSender, MimeKitEmailSender>();
services.AddScoped<IEmailSender, FakeEmailSender>();

More background: Configuring a Local Test Email Server.

Logging and telemetry

The Web project uses Serilog for console output (configured in the Serilog section of appsettings.json; file and Application Insights sinks are sketched in comments) and OpenTelemetry for logs, metrics, and traces through builder.AddServiceDefaults(). When running under Aspire, all of it appears in the dashboard.

Troubleshooting

HTTPS certificate errors

The site uses HTTPS and expects a trusted ASP.NET Core development certificate for localhost:

dotnet dev-certs https --trust

If Chrome still complains, see this answer for mitigation steps.

Docker isn’t running

The Aspire host can’t start the SQL Server or Papercut containers without Docker (or another supported container runtime). Start Docker Desktop, or use option 2.

Port 25 or 37408 is already in use

Papercut binds host ports 25 (SMTP) and 37408 (web UI). Stop whatever else is using them, or change the ports in the app host’s AppHost.cs (and Mailserver:Port to match).

LocalDB isn’t installed (Windows)

Install SQL Server Express LocalDB (included with Visual Studio’s ASP.NET workload), point DefaultConnection at another SQL Server, or (full template) remove DefaultConnection so the app falls back to SQLite.