DEV Community

Cover image for Supercharge your .NET Configuration with Flash.Configuration
Nickolay Selyutin
Nickolay Selyutin

Posted on • Edited on • Originally published at Medium

Supercharge your .NET Configuration with Flash.Configuration

Configuration is the backbone of any modern .NET application. Whether you’re setting up connection strings, feature flags, or API keys, managing configuration effectively can make or break your app’s scalability and maintainability.

.NET provides built-in configuration providers (like appsettings.json and environment variables), but let’s be real — they have their limitations:

  • Static at Runtime — Once your app is running, changing configuration usually means a restart (without reloadOnChange: true).

  • Hard to Modify Post-Build — Need to update a setting after deployment? Good luck scripting that manually.

  • Messy Environment Handling — Maintaining multiple appsettings.{Environment}.json files quickly becomes a nightmare.

Tired of static, hard-to-manage .NET configuration that requires restarts and complex scripts just to update? Wouldn’t it be great if your .NET configuration was dynamic, environment-aware, and easy to modify post-build?? That’s where Flash.Configuration comes in.

Meet Flash.Configuration — Your New Best Friend

Flash.Configuration is a powerful configuration library that solves the pain points of built-in .NET configuration.

Key Features:

Dynamic Parsing — Easily modify settings without restarting your app.
Environment-Specific Configs — Automatically apply different settings for Dev, Staging, and Production.
Post-Build Updates — Modify appsettings.json after deployment.
Strongly Typed Configuration – No more IConfiguration["SomeSetting"]; use strongly typed classes.

In the next section, we’ll walk through a practical example to demonstrate how Flash.Configuration simplifies .NET configuration.

Getting Started with Flash.Configuration 🚀

Use the packages on nuget.org. Flash.Configuration supports Console Applications, Web APIs, Class Libraries, Worker Services, and Web API (Native AOT). If you’re working with WPF, install Flash.Configuration.Wpf. For Windows applications, use Flash.Configuration.WinForms.
📦 GitHub: https://github.com/HawkN113/Flash.Configuration

Defining Strongly Typed Configuration

Instead of dealing with IConfiguration, define a strongly typed class and use [FlashConfig] attributes to map settings dynamically.

[FlashConfig("ConnectionStrings", environment: "Development")]
[FlashConfig("ConnectionStrings", environment: "Production")]
public class ConnectionStrings
{
    [FlashProperty("DefaultConnection")]
    [FlashValue("Server=dev.db;Database=DevDB;User=dev;Password=123;", environment: "Development")]
    [FlashValue("Server=prod.db;Database=ProdDB;User=prod;Password=123;", environment: "Production")]
    public string DefaultConnection { get; } = string.Empty;

    [FlashProperty("Enabled")]
    [FlashValue(false, environment: "Development")]
    [FlashValue(true, environment: "Production")]
    public bool Enabled { get; }
}
Enter fullscreen mode Exit fullscreen mode

💡 What’s Happening Here?

  • The ConnectionStrings class maps to appsettings.Development.json and appsettings.Production.json.
  • Environment-specific values are set dynamically. In the project and in the output project location (i.e: /bin/Debug or /bin/Release)
  • No magic strings — just clean, strongly typed config.

With Flash.Configuration, you don’t need to edit application configuration manually! It automatically updates config files based on environment settings.

After switching to Development:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=dev.db;Database=DevDB;User=dev;Password=123;",
    "Enabled": false
  }
}
Enter fullscreen mode Exit fullscreen mode

After switching to Production:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=prod.db;Database=ProdDB;User=prod;Password=123;",
    "Enabled": true
  }
}
Enter fullscreen mode Exit fullscreen mode

No more manual edits. No more incorrect environment settings. 🎯

Ignoring Configuration Sections

To ignore specific configuration sections, use the [FlashIgnore] attribute:

[FlashIgnore]
[FlashConfig("ConnectionStrings", environment: "Development")]
[FlashConfig("ConnectionStrings", environment: "Production")]
public class ConnectionStrings
{
    [FlashProperty("DefaultConnection")]
    [FlashValue("Server=dev.db;Database=DevDB;User=dev;Password=123;", environment: "Development")]
    [FlashValue("Server=prod.db;Database=ProdDB;User=prod;Password=123;", environment: "Production")]
    public string DefaultConnection { get; } = string.Empty;

    [FlashProperty("Enabled")]
    [FlashValue(false, environment: "Development")]
    [FlashValue(true, environment: "Production")]
    public bool Enabled { get; }
}
Enter fullscreen mode Exit fullscreen mode

If you need to ignore a specific property for a given environment, use [FlashValueIgnore] attribute:

[FlashConfig("FileLogging")]
[FlashConfig("FileLogging", environment: "Staging")]
public class FileLogging
{
    [FlashProperty("Enabled")]
    [FlashValueIgnore(environment: "Staging")]
    public bool Enabled { get; set; } = true;

    [FlashProperty("LogFilePath")]
    [FlashValue("logs/app-stg-log.txt", environment: "Staging")]
    public string LogFilePath { get; set; } = "logs/app-log.txt";
}
Enter fullscreen mode Exit fullscreen mode

After switching to root configuration appSettings.json:

{  
  "FileLogging": {
    "Enabled": true,
    "LogFilePath": "logs/app-log.txt"
  }
}
Enter fullscreen mode Exit fullscreen mode

After switching to Staging:

{  
  "FileLogging": {
    "LogFilePath": "logs/app-stg-log.txt"
  }
}
Enter fullscreen mode Exit fullscreen mode

You can find more features on original post.

Why Should You Use Flash.Configuration? 🤔

If you’re building .NET 8 applications and tired of wrestling with static configuration, Flash.Configuration is the ultimate solution.

🔥 Top Benefits

Eliminates Configuration Headaches — Provides strongly typed, structured, and automated configuration management.
Seamless Integration — Works effortlessly with existing .NET apps without requiring major rewrites.
Post-Build Configuration Handling — Automatically modifies configuration files after build, adapting settings for different environments (Development, Staging, Production).
Built-in Validation & Error Handling — Detects and reports misconfigurations with logging and troubleshooting support.
Dynamic Parsing — Reads and structures JSON-based configuration for easy access and manipulation.
IOptions Support — Fully compatible with .NET’s IOptions pattern for strongly typed configuration.
Faster Deployments — Eliminates manual post-build tweaks, saving valuable time.

💡 Ideal Use Cases

🚀 Microservices & Cloud-Native Apps — Ensures scalable and dynamic configuration management.
🏢 Enterprise-Level Projects — Perfect for complex applications requiring environment-based settings.
🛠 Small & Medium Projects — Simplifies configuration handling without extra complexity.

With Flash.Configuration, managing application settings becomes effortless — so you can focus on building great software! 🚀

Conclusion 🎯

Flash.Configuration transforms .NET configuration from a static headache into a dynamic, scalable experience. If you build modern apps with evolving environments, this library is for you.

By integrating Flash.Configuration, you can:
Streamline configuration workflows — Strongly typed, structured, and automated settings.
Enhance security — Ensure that sensitive data, such as API keys and credentials, is properly managed and protected.
Improve scalability & maintainability — Easily adapt to evolving application needs.
Future-proof your architecture — Designed to work seamlessly with .NET 8 and beyond.

As part of future development, Flash.Configuration aims to introduce advanced sensitive data protection mechanisms, such as secure storage integrations and automated secret management, to further enhance security.

Original Medium Post

Top comments (2)

Collapse
 
vaso profile image
Vaclav Elias

Regarding this point, I would reword it.

Static at Runtime — Once your app is running, changing configuration usually means a restart.

The reason is, there is an option to reload, which isn't complicated if it is needed by the app.

builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

Setting reloadOnChange: true allows auto-reloading of appsettings.json when the file changes, no restart needed but you need to inject IOptionsSnapshot<T> or IOptionsMonitor<T> to get updated values instead of IOptions<T>.

Collapse
 
hawkn113 profile image
Nickolay Selyutin

Thanks. I will prepare the article with advanced settings where i'd like to use Flash.Configuration both variants IOptionsSnapshot<T> and IOptions<T>