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

Views

Import feature flag helpers globally

In your _ViewImports.cshtml add the following line

@addTagHelper *, Microsoft.FeatureManagement.AspNetCore

Anywhere in your views you can now surround the parts of the page that make up the feature

<feature name="FeatureX">
    <p>This can only be seen if 'FeatureX' is enabled.</p>
</feature>

or add display the contents conditionally if Any or All the referenced features are enabled

<feature name="ShoppingCart,Checkout,Donation" requirement="Any">
    <div>checkout logic</div>
</feature>

It's good practice to create a static class or strings or an enum for your features collection to avoid typos. Feature flags in C# work with both strings and enums

PreviousFeature Flags in C# / .NETNextControllers & Actions

Last updated 2 years ago

Was this helpful?

🔘