toggly
  • What is toggly?
  • 🚀Getting started
    • Creating your first project
    • Using our Feature Flag Demo
    • Inviting Your Team
    • API Documentation
  • 🔘Feature Flags
    • Feature Flags in C# / .NET
      • Views
      • Controllers & Actions
      • Dependency Injection
      • Routing
      • IFeatureManagerSnapshot
      • Persistent Flags Across Requests
      • Disabled Action Handling
      • State Change Handlers
      • Custom Context
      • Snapshot Providers
        • RavenDB
        • Entity Framework
      • Debugging Endpoint
      • Serving Front-end Flags
      • Undefined Features In Development
      • Deployments and Version
    • Feature Flags in Vue.js
      • Feature Component
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in JavaScript
      • Directly Checking a Flag
      • Definition Refresh
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in Flutter
      • Feature Widget
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in HTML/CSS
  • 📈Metrics
    • Metrics in C# / .NET
      • Feature Usage
      • Business Metrics
      • Performance Metrics
  • 👩‍💻Use Cases
    • For Engineers
      • Develop continuously, turn on when ready
    • For Product Managers
      • Measure Feature Impact
    • For Agile Teams
      • Faster QA Cycles
      • Streamline Your Releases
Powered by GitBook
On this page

Was this helpful?

  1. Feature Flags
  2. Feature Flags in C# / .NET

IFeatureManagerSnapshot

The IFeatureManagerSnapshot service can be injected anywhere else more suitable helper methods aren't available.

private readonly IFeatureManagerSnapshot _featureManager;

public UsersController(IFeatureManagerSnapshot featureManager)
{
    _featureManager = featureManager;
}

[Route("")]
public async Task<IActionResult> Index()
{
    var feature1Enabled = await _featureManager.IsEnabledAsync(FeatureFlags.Feature1);

    return View(feature1Enabled ? "Feature1Index" : "Index");
}

IFeatureManagerSnapshot persists the values of the flags returned throughout the current request, and is recommended to be used over calling IFeatureManager directly, so you don't end up with different values for the a flag on the same request.

IFeatureManager is used by the FeatureMangerSnapshot to retrieve the computed value of each flag on each call, and it can be used the same way IFeatureManagerSnapshot is used.

PreviousRoutingNextPersistent Flags Across Requests

Last updated 2 years ago

Was this helpful?

🔘