This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies that a parameter or property should be bound using the request services.
public ref class FromServicesAttribute : Attribute, Microsoft::AspNetCore::Mvc::ModelBinding::IBindingSourceMetadata[System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)]public class FromServicesAttribute : Attribute, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata[System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)]public class FromServicesAttribute : Attribute, Microsoft.AspNetCore.Http.Metadata.IFromServiceMetadata, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata[System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)]public class FromServicesAttribute : Attribute, Microsoft.AspNetCore.Http.Metadata.IFromServiceMetadata, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata[<System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)>]type FromServicesAttribute = class inherit Attribute interface IBindingSourceMetadata[<System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)>]type FromServicesAttribute = class inherit Attribute interface IBindingSourceMetadata interface IFromServiceMetadata[<System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)>]type FromServicesAttribute = class inherit Attribute interface IBindingSourceMetadata interface IFromServiceMetadataPublic Class FromServicesAttributeInherits AttributeImplements IBindingSourceMetadataPublic Class FromServicesAttributeInherits AttributeImplements IBindingSourceMetadata, IFromServiceMetadataIn this example an implementation of IProductModelRequestService is registered as a service.Then in the GetProduct action, the parameter is bound to an instance of IProductModelRequestServicewhich is resolved from the request services.
[HttpGet]public ProductModel GetProduct([FromServices] IProductModelRequestService productModelRequest){ return productModelRequest.Value;}| Name | Description |
|---|---|
| FromServicesAttribute() | |
| Name | Description |
|---|---|
| BindingSource | Gets theBindingSource. |
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?