![]() |
VOOZH | about |
dotnet add package DotNetBrightener.SiteSettings --version 2026.0.2
NuGet\Install-Package DotNetBrightener.SiteSettings -Version 2026.0.2
<PackageReference Include="DotNetBrightener.SiteSettings" Version="2026.0.2" />
<PackageVersion Include="DotNetBrightener.SiteSettings" Version="2026.0.2" />Directory.Packages.props
<PackageReference Include="DotNetBrightener.SiteSettings" />Project file
paket add DotNetBrightener.SiteSettings --version 2026.0.2
#r "nuget: DotNetBrightener.SiteSettings, 2026.0.2"
#:package DotNetBrightener.SiteSettings@2026.0.2
#addin nuget:?package=DotNetBrightener.SiteSettings&version=2026.0.2Install as a Cake Addin
#tool nuget:?package=DotNetBrightener.SiteSettings&version=2026.0.2Install as a Cake Tool
Copyright © 2017 - 2026 Vampire Coder (formerly DotnetBrightener)
The DotNetBrightener SiteSettings module provides a comprehensive solution for managing application-wide configuration settings in .NET applications. It offers a flexible, type-safe approach to storing and retrieving settings with built-in caching, database persistence, and RESTful API endpoints.
The module follows a layered architecture:
SiteSettingsController)ISiteSettingService, SiteSettingService)ISiteSettingDataService)SiteSettingBase, SiteSettingWrapper<T>)<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
For SQL Server:
<PackageReference Include="DotNetBrightener.SiteSettings.Data.Mssql" Version="[latest]" />
For PostgreSQL:
<PackageReference Include="DotNetBrightener.SiteSettings.Data.PostgreSql" Version="[latest]" />
# Core package
dotnet add package DotNetBrightener.SiteSettings
# Choose your database provider
dotnet add package DotNetBrightener.SiteSettings.Data.Mssql
# OR
dotnet add package DotNetBrightener.SiteSettings.Data.PostgreSql
Create strongly-typed setting classes by inheriting from SiteSettingWrapper<T>:
using DotNetBrightener.SiteSettings.Models;
public class ApplicationSettings : SiteSettingWrapper<ApplicationSettings>
{
public string ApplicationName { get; set; } = "My Application";
public string SupportEmail { get; set; } = "support@example.com";
public int MaxFileUploadSize { get; set; } = 10485760; // 10MB
public bool EnableNotifications { get; set; } = true;
public override string SettingName => "Application Settings";
public override string Description => "General application configuration settings";
}
public class EmailSettings : SiteSettingWrapper<EmailSettings>
{
public string SmtpServer { get; set; } = "localhost";
public int SmtpPort { get; set; } = 587;
public string Username { get; set; }
public string Password { get; set; }
public bool EnableSsl { get; set; } = true;
public override string SettingName => "Email Settings";
public override string Description => "SMTP configuration for email sending";
}
using DotNetBrightener.SiteSettings;
using DotNetBrightener.SiteSettings.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add localization support
builder.Services.AddLocalization();
// Add MVC services
var mvcBuilder = builder.Services.AddControllersWithViews();
// Register SiteSettings API
mvcBuilder.RegisterSiteSettingApi();
// Configure database storage (choose one)
// For SQL Server:
builder.Services.AddSiteSettingsSqlServerStorage(
builder.Configuration.GetConnectionString("DefaultConnection"));
// For PostgreSQL:
// builder.Services.AddSiteSettingsPostgreSqlStorage(
// builder.Configuration.GetConnectionString("DefaultConnection"));
// Register your setting types
builder.Services.RegisterSettingType<ApplicationSettings>();
builder.Services.RegisterSettingType<EmailSettings>();
var app = builder.Build();
// Configure the HTTP request pipeline
app.MapControllers();
app.Run();
Add connection string to appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=MyApp;Trusted_Connection=true;TrustServerCertificate=true;"
}
}
The module will automatically create the required database schema and tables on first run.
The module exposes the following RESTful endpoints:
GET /api/SiteSettings/allSettings
Response:
[
{
"settingName": "Application Settings",
"description": "General application configuration settings",
"settingType": "MyApp.ApplicationSettings"
}
]
GET /api/SiteSettings/{settingKey}
Example:
GET /api/SiteSettings/MyApp.ApplicationSettings
Response:
{
"applicationName": "My Application",
"supportEmail": "support@example.com",
"maxFileUploadSize": 10485760,
"enableNotifications": true
}
GET /api/SiteSettings/{settingKey}/default
POST /api/SiteSettings/{settingKey}
Content-Type: application/json
{
"applicationName": "Updated App Name",
"supportEmail": "newsupport@example.com",
"maxFileUploadSize": 20971520,
"enableNotifications": false
}
using DotNetBrightener.SiteSettings.Abstractions;
[ApiController]
[Route("api/[controller]")]
public class MyController : ControllerBase
{
private readonly ISiteSettingService _settingService;
public MyController(ISiteSettingService settingService)
{
_settingService = settingService;
}
[HttpGet("app-info")]
public IActionResult GetAppInfo()
{
var appSettings = _settingService.GetSetting<ApplicationSettings>();
return Ok(new
{
Name = appSettings.ApplicationName,
Support = appSettings.SupportEmail,
MaxUpload = appSettings.MaxFileUploadSize
});
}
[HttpPost("update-settings")]
public IActionResult UpdateSettings([FromBody] ApplicationSettings settings)
{
_settingService.SaveSetting(settings);
return Ok();
}
}
The module uses the DotNetBrightener caching system. Settings are cached for 10 minutes by default. Configure caching in your startup:
// Add memory caching
builder.Services.AddMemoryCache();
// Or Redis caching
builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = "localhost:6379";
});
The module creates tables in the following schema:
SQL Server: SiteSettings.SiteSettingRecord
PostgreSQL: site_settings.site_setting_record
Table Structure:
Id (bigint, primary key)SettingType (nvarchar(1024)) - Fully qualified type nameSettingContent (nvarchar(max)) - JSON serialized settingsCreatedDate, CreatedBy, ModifiedDate, ModifiedByIsDeleted, DeletedDate, DeletedBy, DeletionReasonThe module provides localized error messages. Common error scenarios:
{
"errorMessage": "Setting 'InvalidType' not found"
}
{
"errorMessage": "Setting type must inherit from SiteSettingBase"
}
The module uses a custom JSON contract resolver (SiteSettingsContractResolver) for consistent serialization.
When retrieving settings, the module automatically merges saved values with default values, ensuring backward compatibility when new properties are added to setting classes.
All setting changes are automatically tracked with creation and modification timestamps and user information.
[Test]
public void Should_Save_And_Retrieve_Settings()
{
// Arrange
var settings = new ApplicationSettings
{
ApplicationName = "Test App",
SupportEmail = "test@example.com"
};
// Act
_settingService.SaveSetting(settings);
var retrieved = _settingService.GetSetting<ApplicationSettings>();
// Assert
Assert.AreEqual("Test App", retrieved.ApplicationName);
Assert.AreEqual("test@example.com", retrieved.SupportEmail);
}
Database Connection Issues
Migration Issues
Caching Issues
Serialization Issues
SettingType columnISiteSettingService instead of IConfigurationSaveSetting method to populate the new systemThis integration guide provides everything needed to successfully implement the DotNetBrightener SiteSettings module in your .NET applications.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on DotNetBrightener.SiteSettings:
| Package | Downloads |
|---|---|
|
DotNetBrightener.SiteSettings.Data.Mssql
Package Description |
|
|
DotNetBrightener.SiteSettings.Data.PostgreSql
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.0.3-preview-777 | 128 | 5/20/2026 |
| 2026.0.3-preview-773 | 133 | 4/24/2026 |
| 2026.0.3-preview-772 | 156 | 4/3/2026 |
| 2026.0.3-preview-770 | 120 | 4/2/2026 |
| 2026.0.3-preview-769 | 115 | 4/2/2026 |
| 2026.0.2 | 145 | 4/2/2026 |
| 2026.0.2-preview-v2026-0-1-755 | 121 | 3/27/2026 |
| 2026.0.2-preview-759 | 128 | 4/1/2026 |
| 2026.0.2-preview-758 | 125 | 3/29/2026 |
| 2026.0.2-preview-757 | 121 | 3/29/2026 |
| 2026.0.2-preview-756 | 124 | 3/27/2026 |
| 2026.0.2-preview-754 | 108 | 3/27/2026 |
| 2026.0.1 | 130 | 3/27/2026 |
| 2026.0.1-preview-752 | 115 | 3/26/2026 |
| 2026.0.1-preview-750 | 114 | 3/26/2026 |
| 2026.0.1-preview-749 | 119 | 3/25/2026 |
| 2025.0.11-preview-776 | 121 | 5/20/2026 |
| 2025.0.11-preview-771 | 131 | 4/2/2026 |
| 2025.0.11-preview-768 | 126 | 4/2/2026 |
| 2025.0.11-preview-762 | 124 | 4/2/2026 |