- Home
- .NET code examples
- Validate .NET configuration on startup example
Validate .NET configuration on startup example
Download the code example to validate configuration on startup using data annotations and FluentValidation.
You can learn more about how to validate configuration on startup with our tutorial, or watch the video.
Download the code example
You'll need to fill out the code example form. We will send you an email where you can download the code example.
Software
This is the software that will need to be installed onto your machine.
Visual Studio 2026. Version 18.0.0 or above. It will work with the free community version.
.NET 10 SDK. Version 10.0.0 or above.
The application
In the code example, there are separate applications for the data annotations and FluentValidation examples. These are separated into folders.
For each one:
Open up RoundTheCode.AppStartup.slnx. It should open it up in Visual Studio 2026.
Run the application. It will run in Production, throw an exception and fail to start.
In the Api project, add appsettings.Production.json with the following config:
{
"Payment": {
"BaseUri": "https://mypayment.com",
"ApiKey": "e6859d092c1ef5cf3655a553733502bd"
},
"Email": {
"SmtpHost": "mysmtp.host"
}
}Start the application again. It will run in Production and start successfully.
Latest code examples