Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Mvc/Mvc.Core/src/FromBodyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ namespace Microsoft.AspNetCore.Mvc;
/// Specifies that a parameter or property should be bound using the request body.
/// </summary>
/// <remarks>
/// Binds a parameter or property to the request body.
///
/// By default, ASP.NET Core MVC delegates the responsibility of reading the body to an input formatter.<br/>
/// In the case of ASP.NET Core Minimal APIs, the body is deserialized by <see cref="System.Text.Json.JsonSerializer"/>.
///
/// For more information about parameter binding see
/// <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/parameter-binding?">Parameter binding</see>.
/// </remarks>
/// <example>
/// In this example, the value of the 'name' field in the form-data request body is bound to the name parameter,
/// and the value of the 'age' field is bound to the age parameter.
/// <code>
/// app.MapPost("/from-body", ([FromBody] Person person) => person);
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class FromBodyAttribute : Attribute, IBindingSourceMetadata, IConfigureEmptyBodyBehavior, IFromBodyMetadata
{
Expand Down
16 changes: 16 additions & 0 deletions src/Mvc/Mvc.Core/src/FromFormAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ namespace Microsoft.AspNetCore.Mvc;
/// <summary>
/// Specifies that a parameter or property should be bound using form-data in the request body.
/// </summary>
/// <remarks>
/// Binds a parameter or property to a field in a form-data request body with the same name,
/// or the name specified in the <see cref="Name"/> property.
/// Form parameter names are matched case-insensitively.
///
/// For more information about parameter binding see
/// <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/parameter-binding?">Parameter binding</see>.
/// </remarks>
/// <example>
/// In this example, the value of the 'name' field in the form-data request body is bound to the name parameter,
/// and the value of the 'age' field is bound to the age parameter.
/// <code>
/// app.MapPost("/from-form", ([FromForm] string name, [FromForm] int age)
/// => new { Name = name, Age = age });
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class FromFormAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider, IFromFormMetadata
{
Expand Down
15 changes: 15 additions & 0 deletions src/Mvc/Mvc.Core/src/FromHeaderAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ namespace Microsoft.AspNetCore.Mvc;
/// <summary>
/// Specifies that a parameter or property should be bound using the request headers.
/// </summary>
/// <remarks>
/// Binds a parameter or property to the value of the request header with the same name,
/// or the name specified in the <see cref="Name"/> property.
/// Note that HTTP header names are case-insensitive, so the header name is matched without regard to case.
///
/// For more information about parameter binding see
/// <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/parameter-binding?">Parameter binding</see>.
/// </remarks>
/// <example>
/// In this example, the value of the 'User-Agent' header is bound to the parameter.
/// <code>
/// app.MapGet("/user-agent", ([FromHeader(Name = "User-Agent")] string userAgent)
/// => userAgent);
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class FromHeaderAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider, IFromHeaderMetadata
{
Expand Down
15 changes: 15 additions & 0 deletions src/Mvc/Mvc.Core/src/FromQueryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ namespace Microsoft.AspNetCore.Mvc;
/// <summary>
/// Specifies that a parameter or property should be bound using the request query string.
/// </summary>
/// <remarks>
/// Binds a parameter or property to the value of query string parameter with the same name,
/// or the name specified in the <see cref="Name"/> property.
/// The query parameter name is matched case-insensitively.
///
/// For more information about parameter binding see
/// <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/parameter-binding?">Parameter binding</see>.
/// </remarks>
/// <example>
/// In this example, the value of the 'User-Agent' header is bound to the parameter.
/// <code>
/// app.MapGet("/version", ([FromQuery(Name = "api-version")] string apiVersion)
/// => apiVersion);
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class FromQueryAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider, IFromQueryMetadata
{
Expand Down
14 changes: 14 additions & 0 deletions src/Mvc/Mvc.Core/src/FromRouteAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ namespace Microsoft.AspNetCore.Mvc;
/// <summary>
/// Specifies that a parameter or property should be bound using route-data from the current request.
/// </summary>
/// <remarks>
/// Binds a parameter or property to the value of a route parameter with the same name,
/// or the name specified in the <see cref="Name"/> property.
/// The route parameter name is matched against parameter segments of the route pattern case-insensitively.
///
/// For more information about parameter binding see
/// <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/parameter-binding?">Parameter binding</see>.
/// </remarks>
/// <example>
/// In this example, the value of the 'id' route parameter is bound to the parameter.
/// <code>
/// app.MapGet("/from-route/{id}", ([FromRoute] string id) => id);
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class FromRouteAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider, IFromRouteMetadata
{
Expand Down
Loading