Top-Level Settings
These settings configure the application identity, server binding, and configuration behavior.
Application Settings
{
"ApplicationName": null,
"EnvironmentName": "Production",
"Urls": "http://localhost:8080",
"StartupMessage": "Started in {time}, listening on {urls}, version {version}"
}Settings Reference
| Setting | Type | Default | Description |
|---|---|---|---|
ApplicationName | string | null | Application identifier. Defaults to the top-level directory name if not set. |
EnvironmentName | string | "Production" | Environment designation (Development, Staging, Production). |
Urls | string | "http://localhost:8080" | Server listening URLs. Separate multiple URLs with semicolons. |
StartupMessage | string | (see below) | Message displayed on startup. Supports placeholders. |
Default StartupMessage: "Started in {time}, listening on {urls}, version {version}"
Urls Configuration
The Urls setting accepts multiple URLs separated by semicolons:
{
"Urls": "http://localhost:8080;https://localhost:8443"
}To listen on all interfaces:
{
"Urls": "http://0.0.0.0:8080;https://0.0.0.0:8443"
}Startup Message Placeholders
Customize the startup message with these placeholders:
| Placeholder | Description |
|---|---|
{time} | Startup time |
{urls} | Listening URLs |
{version} | Application version |
{environment} | Environment name (from EnvironmentName) |
{application} | Application name (from ApplicationName) |
Example:
{
"StartupMessage": "Started in {time}, listening on {urls}, version {version}, env: {environment}"
}Config Section
The Config section controls how the configuration file itself is processed.
{
"Config": {
"ExposeAsEndpoint": null,
"AddEnvironmentVariables": false,
"ParseEnvironmentVariables": true
}
}Settings Reference
| Setting | Type | Default | Description |
|---|---|---|---|
ExposeAsEndpoint | string | null | Expose current configuration to an endpoint for debugging. Set to a path like "/config" to enable. Passwords in connection strings are not exposed. |
AddEnvironmentVariables | bool | false | Allow environment variables to override configuration settings. |
ParseEnvironmentVariables | bool | true | Parse {ENV_VAR_NAME} placeholders in config values and replace with environment variable values. |
Environment Variable Override
When AddEnvironmentVariables is true, environment variables can override any configuration setting. Use double underscores for nested keys:
# Override ConnectionStrings.Default
export ConnectionStrings__Default="Host=production-server;..."
# Override NpgsqlRest.UrlPathPrefix
export NpgsqlRest__UrlPathPrefix="/v2/api"Environment Variable Parsing
When ParseEnvironmentVariables is true (default), you can use {ENV_VAR} syntax anywhere in configuration values:
{
"ConnectionStrings": {
"Default": "Host={PGHOST};Port={PGPORT};Database={PGDATABASE};Username={PGUSER};Password={PGPASSWORD}"
}
}This allows sensitive values to be kept in environment variables rather than in the configuration file.
Exposing Configuration
For debugging purposes, you can expose the current configuration as an endpoint:
{
"Config": {
"ExposeAsEndpoint": "/config"
}
}This creates a GET /config endpoint that returns the current configuration as JSON. Passwords in connection strings are automatically redacted.
Related
- Comment Annotations Guide - How annotations work
- Configuration Guide - How configuration sources work
Next Steps
- Connection Settings - Database connection strings
- Server & SSL - Kestrel and HTTPS configuration