appSettings.json files
The installed application is configured in the appsettings.json file of the Server project. This configuration is used by the server, and part of it is transmitted to the Blazor WebAssembly client.
warning
The only keys usable on the client side are those of the App section and its subsections. Do not place secrets in App, since these values are exposed to the browser.
File format
{
"ConnectionStrings": {
"DefaultConnection": "DataSource=app.db"
},
"MySampleSection": {
"MySampleKey": "Value of my key"
},
"App": {
"Name": "LagoonDev",
"EnvironmentName": "DEV",
"EnvironmentColor": "#0045BC",
"MyAppClientCustomKey": "My value",
"About": {
"AdditionalInformation": [
{
"Label": "My label:",
"Description": "Lorem ipsum",
"Uri": "https://example.com"
}
]
},
"ClientLogger": {
"SyncErrorDelay": 1800,
"MaxResendErrorAttempts": 10,
"MaxLocalErrorsCount": 200
}
}
}
Using the configuration on the server side
Inject IConfiguration into the services, controllers, or server classes that need to read the configuration.
MyService.cs
public class MyService
{
private readonly IConfiguration _configuration;
public MyService(IConfiguration configuration)
{
_configuration = configuration;
}
public string GetConfiguredValue()
{
// Reads an application value with a default value if the key is missing.
return _configuration.GetValue("MySampleSection:MySampleKey", "MyDefaultValue");
}
}
The indexer syntax is also available: configuration["MySampleSection:MySampleKey"].
Using the configuration on the client side
On the client side, only keys under App are available.
MyClientService.cs
public class MyClientService
{
private readonly IConfiguration _configuration;
public MyClientService(IConfiguration configuration)
{
_configuration = configuration;
}
public string GetClientValue()
{
// The key must belong to the App section to be transmitted to the client.
return _configuration.GetValue("App:MyAppClientCustomKey", "MyDefaultValue");
}
}
Common Lagoon sections
| Section | Usage |
|---|---|
ConnectionStrings | Connection strings used by the application DbContext. |
AutoUpdateDatabase | Indicates whether the server applies migrations at startup when Main.OnStartAsync reads it. |
Logging | ASP.NET Core logging levels. |
App | Application information available on both the server and client sides. |
Lagoon | Server-side framework settings: public URL, logging, SMTP, CSP, OpenID certificate, etc. |
App section
| Key | Description | Default |
|---|---|---|
Name | Application name. | Application root name. |
EnvironmentName | Short environment name displayed if EnvironmentDisplayName is absent, for example PROD or DEV. | Not set. |
EnvironmentDisplayName | Environment name displayed; if absent, Lagoon uses EnvironmentName. | EnvironmentName. |
EnvironmentColor | Color associated with the current environment. | Not set. |
PostLogoutUri | URL called after logout. | Not set. |
PostLogoutMode | Mode used to call PostLogoutUri: Navigation or XHR. | Navigation. |
About:AdditionalInformation | Additional information displayed on the About page. | No entry. |
ClientLogger:SyncErrorDelay | Client error synchronization delay, in seconds. | 1800. |
ClientLogger:MaxResendErrorAttempts | Maximum number of client error resend attempts. | 10. |
ClientLogger:MaxLocalErrorsCount | Maximum number of client errors kept locally. | 200. |
PostLogoutMode accepts two behaviors:
| Value | Effect |
|---|---|
Navigation | Navigates to the PostLogoutUri URL after logout. |
XHR | Calls PostLogoutUri asynchronously without waiting for the result. |
Lagoon section
The following keys are used by Lagoon modules when the corresponding features are enabled.
| Key | Usage |
|---|---|
PublicUrl | Public URL of the application. It is notably used to build the CSP and public URLs. |
RemotePublicUrl | Value transmitted to the client to check consistency with <base href>. |
ConfigPageToken | Token protecting the server configuration page. |
AutoUpdateDatabase | Indicates whether the framework applies migrations at startup. |
Authentication:OpendIdCertificate | Name or path of the OpenID certificate used by the server. |
Authentication:CertificateBase64 | OpenID certificate as a string: <certificate>.<private key> in base64, or base64 of a pfx. Takes precedence over files. |
DefaultLoggers | Retention of pre-registered ASP.NET Core loggers. |
LightConsoleLogger | Simplified console logging. |
FileLogger | Lagoon file logging. |
Smtp | Server-side email sending. |
CSP | Content Security Policy generated by Lagoon. |
EulaFiles | HTML EULA/terms-of-use files used by shared mode. |
ChromiumPath | Path to the Chromium instance used by Lagoon.PDF when installed. |
Environments
appsettings.jsoncontains the base configuration.appsettings.Development.jsonoverrides this configuration in development.- Production secrets must be provided by the runtime environment or by the host's secure configuration, not versioned in plain text.