Skip to content

Commit

Permalink
Update FeatureGatedAsyncActionFilter.cs (#260)
Browse files Browse the repository at this point in the history
use `context.HttpContext.RequestServices` directly

Co-authored-by: Zhiyuan Liang <141655842+zhiyuanliang-ms@users.noreply.github.com>
  • Loading branch information
WeihanLi and zhiyuanliang-ms committed Jan 23, 2024
1 parent c7a9668 commit 58121f7
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionE

if (await featureManager.IsEnabledAsync(FeatureName).ConfigureAwait(false))
{
IServiceProvider serviceProvider = context.HttpContext.RequestServices.GetRequiredService<IServiceProvider>();

IAsyncActionFilter filter = ActivatorUtilities.CreateInstance<T>(serviceProvider);
IAsyncActionFilter filter = ActivatorUtilities.CreateInstance<T>(context.HttpContext.RequestServices);

await filter.OnActionExecutionAsync(context, next).ConfigureAwait(false);
}
Expand Down

0 comments on commit 58121f7

Please sign in to comment.