Skip to content

Commit f7e9e4a

Browse files
make the answer shorter
1 parent d4f74e5 commit f7e9e4a

File tree

1 file changed

+2
-4
lines changed
  • articles/azure-app-configuration

1 file changed

+2
-4
lines changed

articles/azure-app-configuration/faq.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,13 @@ sections:
183183
184184
- question: How to use Feature Management in Blazor applications or as scoped services in .NET?
185185
answer: |
186-
The API `AddScopedFeatureManagement` should be used. This will ensure that feature management services, including feature filters, are added as scoped services.
186+
The `AddScopedFeatureManagement` method should be used instead of `AddFeatureManagement`. This will ensure that feature management services, including feature filters, are added as scoped services.
187187
188188
```C#
189189
services.AddScopedFeatureManagement();
190190
```
191191
192-
The `Microsoft.FeatureManagement` library provides the API `AddFeatureManagement` method which adds feature management services as singletons within the application, but there are scenarios where it may be necessary for feature management services to be added as scoped services instead. For example, users may want to use feature filters which consume scoped services for context information. This issue will occur while using the built-in targeting filter in Blazor server applications.
193-
194-
In regular ASP.NET web application, the singleton `IHttpContextAccessor` [pattern](https://learn.microsoft.com/en-us/azure/azure-app-configuration/howto-targetingfilter-aspnet-core#update-the-web-application-code-to-use-targetingfilter) is used to obtain the targeting context from `HttpContext`. However, this pattern does not work for Blazor server applications, because `HttpContext` is unavailable. [The recommended approach](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/server/interactive-server-side-rendering?view=aspnetcore-7.0#ihttpcontextaccessorhttpcontext-in-razor-components) for passing the information of HttpContext in Blazor apps is to copy the data into a scoped service. Then, the targeting context accessor should consume that scoped service to determine the targeting context. In this case, the API `AddScopedFeatureManagement` should be used instead.
192+
Feature filters can evaluate a feature flag based on the properties of an HTTP Request. This is usually performed by inspecting the `HttpContext` through the the singleton `IHttpContextAccessor` [pattern](https://learn.microsoft.com/en-us/azure/azure-app-configuration/howto-targetingfilter-aspnet-core#update-the-web-application-code-to-use-targetingfilter). However, this pattern does not work for [Blazor server applications](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/server/interactive-server-side-rendering?view=aspnetcore-7.0#ihttpcontextaccessorhttpcontext-in-razor-components) where scoped services should be used instead. In this case, `AddScopedFeatureManagement` method should be used.
195193
196194
- question: How can I receive announcements on new releases and other information related to App Configuration?
197195
answer: |

0 commit comments

Comments
 (0)