ConfigCat SDK for .NET provides easy integration for your application to ConfigCat.
ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.
ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
- .NET 5+
- .NET Framework 4.5+
- Other runtimes which implement .NET Standard 2.0+ like .NET Core 2.0+, Xamarin.Android 8.0+, Xamarin.iOS 10.14+, etc. (For more details, please refer to this table.)
Install-Package ConfigCat.Client
or
dotnet add package ConfigCat.Client
using ConfigCat.Client;
3. Go to the ConfigCat Dashboard to get your SDK Key:
var client = ConfigCatClient.Get("#YOUR-SDK-KEY#");
You can acquire singleton client instances for your SDK keys using the
ConfigCatClient.Get(sdkKey: <sdkKey>)
static factory method. (However, please keep in mind that subsequent calls toConfigCatClient.Get()
with the same SDK Key return a shared client instance, which was set up by the first call.)
var isMyAwesomeFeatureEnabled = await client.GetValueAsync("isMyAwesomeFeatureEnabled", false);
if(isMyAwesomeFeatureEnabled)
{
doTheNewThing();
}
else
{
doTheOldThing();
}
client.Dispose();
To ensure graceful shutdown of the client you should invoke
.Dispose()
method. (Client implements IDisposable interface.) Alternatively, you can also close all open clients at once using theConfigCatClient.DisposeAll()
method.
Using this feature, you will be able to get different setting values for different users in your application by passing a User Object
to the GetValue()
function.
Read more about Targeting here.
User currentUser = new User("435170f4-8a8b-4b67-a723-505ac7cdea92");
var isMyAwesomeFeatureEnabled = await client.GetValueAsync(
"isMyAwesomeFeatureEnabled",
defaultValue: false,
user: currentUser);
- Sample Console App
- Sample Multi-page Web App
- Sample Single-page Web App
- Sample Mobile/Windows Store App
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at ConfigCat Docs.
The ConfigCat SDK supports all the widespread .NET JIT runtimes, everything that implements .NET Standard 2.0+ and supports TLS 1.2 should work. Starting with v9.3.0, it can also be used in applications that employ trimmed self-contained or various ahead-of-time (AOT) compilation deployment models.
Based on our tests, the SDK is compatible with the following runtimes/deployment models:
- .NET Framework 4.5+ (including Ngen)
- .NET Core 3.1, .NET 5+ (including Crossgen2/ReadyToRun and Native AOT)
- Mono 5.10+
- .NET for Android (formerly known as Xamarin.Android)
- .NET for iOS (formerly known as Xamarin.iOS)
- Unity 2021.3+ (Mono JIT)
- Unity 2021.3+ (IL2CPP)*
- Universal Windows Platform 10.0.16299.0+ (.NET Native)**
- WebAssembly (Mono AOT/Emscripten, also known as wasm-tools)
*Unity WebGL also works but needs a bit of extra effort: you will need to enable WebGL compatibility by calling the ConfigCatClient.PlatformCompatibilityOptions.EnableUnityWebGLCompatibility
method. For more details, see Sample Scripts.
**To make the SDK work in Release builds on UWP, you will need to add <Namespace Name="System.Text.Json.Serialization.Converters" Browse="Required All"/>
to your application's .rd.xml file. See also this discussion.
We strive to provide an extensive support for the various .NET runtimes and versions. If you still encounter an issue with the SDK on some platform, please open a GitHub issue or contact support.
Contributions are welcome. For more info please read the Contribution Guideline.