You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-25Lines changed: 11 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,20 +138,6 @@ A `RequirementType` of `All` changes the traversal. First, if there are no filte
138
138
```
139
139
140
140
In the above example, `FeatureW` specifies a `RequirementType` of `All`, meaning all of it's filters must evaluate to true for the feature to be enabled. In this case, the feature will be enabled for 50% of users during the specified time window.
141
-
142
-
### Referencing
143
-
144
-
To make it easier to reference these feature flags in code, we recommend to define feature flag variables like below.
145
-
146
-
```C#
147
-
// Define feature flags in an enum
148
-
publicenumMyFeatureFlags
149
-
{
150
-
FeatureT,
151
-
FeatureU,
152
-
FeatureV
153
-
}
154
-
```
155
141
156
142
### Service Registration
157
143
@@ -187,7 +173,7 @@ The basic form of feature management is checking if a feature is enabled and the
187
173
…
188
174
IFeatureManagerfeatureManager;
189
175
…
190
-
if (awaitfeatureManager.IsEnabledAsync(nameof(MyFeatureFlags.FeatureU)))
176
+
if (awaitfeatureManager.IsEnabledAsync("FeatureX"))
191
177
{
192
178
// Do something
193
179
}
@@ -216,7 +202,7 @@ The feature management library provides functionality in ASP.NET Core and MVC to
216
202
MVC controller and actions can require that a given feature, or one of any list of features, be enabled in order to execute. This can be done by using a `FeatureGateAttribute`, which can be found in the `Microsoft.FeatureManagement.Mvc` namespace.
217
203
218
204
```C#
219
-
[FeatureGate(MyFeatureFlags.FeatureX)]
205
+
[FeatureGate("FeatureX")]
220
206
publicclassHomeController : Controller
221
207
{
222
208
…
@@ -226,14 +212,14 @@ public class HomeController : Controller
226
212
The `HomeController` above is gated by "FeatureX". "FeatureX" must be enabled before any action the `HomeController` contains can be executed.
227
213
228
214
```C#
229
-
[FeatureGate(MyFeatureFlags.FeatureY)]
215
+
[FeatureGate("FeatureX")]
230
216
publicIActionResultIndex()
231
217
{
232
218
returnView();
233
219
}
234
220
```
235
221
236
-
The `Index` MVC action above requires "FeatureY" to be enabled before it can execute.
222
+
The `Index` MVC action above requires "FeatureX" to be enabled before it can execute.
237
223
238
224
### Disabled Action Handling
239
225
@@ -251,7 +237,7 @@ public interface IDisabledFeaturesHandler
251
237
In MVC views `<feature>` tags can be used to conditionally render content based on whether a feature is enabled or not.
252
238
253
239
```HTML+Razor
254
-
<feature name=@nameof(MyFeatureFlags.FeatureX)>
240
+
<feature name="FeatureX">
255
241
<p>This can only be seen if 'FeatureX' is enabled.</p>
256
242
</feature>
257
243
```
@@ -277,17 +263,17 @@ The feature management pipeline supports async MVC Action filters, which impleme
The code above adds an MVC filter named `SomeMvcFilter`. This filter is only triggered within the MVC pipeline if the feature it specifies, "FeatureV", is enabled.
270
+
The code above adds an MVC filter named `SomeMvcFilter`. This filter is only triggered within the MVC pipeline if the feature it specifies, "FeatureX", is enabled.
285
271
286
272
### Razor Pages
287
273
MVC Razor pages can require that a given feature, or one of any list of features, be enabled in order to execute. This can be done by using a `FeatureGateAttribute`, which can be found in the `Microsoft.FeatureManagement.Mvc` namespace.
288
274
289
275
```C#
290
-
[FeatureGate(MyFeatureFlags.FeatureU)]
276
+
[FeatureGate("FeatureX")]
291
277
publicclassIndexModel : PageModel
292
278
{
293
279
publicvoidOnGet()
@@ -296,7 +282,7 @@ public class IndexModel : PageModel
296
282
}
297
283
```
298
284
299
-
The code above sets up a Razor page to require the "FeatureU" to be enabled. If the feature is not enabled, the page will generate an HTTP 404 (NotFound) result.
285
+
The code above sets up a Razor page to require the "FeatureX" to be enabled. If the feature is not enabled, the page will generate an HTTP 404 (NotFound) result.
300
286
301
287
When used on Razor pages, the `FeatureGateAttribute` must be placed on the page handler type. It cannot be placed on individual handler methods.
302
288
@@ -305,10 +291,10 @@ When used on Razor pages, the `FeatureGateAttribute` must be placed on the page
305
291
The feature management library can be used to add application branches and middleware that execute conditionally based on feature state.
With the above call, the application adds a middleware component that only appears in the request pipeline if the feature "FeatureU" is enabled. If the feature is enabled/disabled during runtime, the middleware pipeline can be changed dynamically.
297
+
With the above call, the application adds a middleware component that only appears in the request pipeline if the feature "FeatureX" is enabled. If the feature is enabled/disabled during runtime, the middleware pipeline can be changed dynamically.
312
298
313
299
This builds off the more generic capability to branch the entire application based on a feature.
0 commit comments