Add Key Property to ServiceFilterAttribute #58017
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Background and Motivation
Since .NET 8, the service provider supports keyed service registrations. However, the ServiceFilterAttribute, which uses dependency injection from a type, does not allow specifying an optional key for the registration. It should have an optional Key property.
Internally, the only change would be to check if the Key property is not null or whitespace, and then call GetRequiredKeyedService instead of GetRequiredService.
Proposed API
Usage Examples
The text was updated successfully, but these errors were encountered: