parent
01f2fa5394
commit
92565aa6c9
|
@ -127,7 +127,9 @@ A binding source attribute defines the location at which an action parameter's v
|
|||
> [!WARNING]
|
||||
> Don't use `[FromRoute]` when values might contain `%2f` (that is `/`). `%2f` won't be unescaped to `/`. Use `[FromQuery]` if the value might contain `%2f`.
|
||||
|
||||
Without the `[ApiController]` attribute, binding source attributes are explicitly defined. In the following example, the `[FromQuery]` attribute indicates that the `discontinuedOnly` parameter value is provided in the request URL's query string:
|
||||
Without the `[ApiController]` attribute, binding source attributes are explicitly defined. Without `[ApiController]` or other binding source attributes like `[FromQuery]`, the ASP.NET Core runtime attempts to use the complex object model binder. The complex object model binder pulls data from value providers (which have a defined order). For instance, the 'body model binder' is always opt in.
|
||||
|
||||
In the following example, the `[FromQuery]` attribute indicates that the `discontinuedOnly` parameter value is provided in the request URL's query string:
|
||||
|
||||
[!code-csharp[](define-controller/samples/WebApiSample.Api.21/Controllers/ProductsController.cs?name=snippet_BindingSourceAttributes&highlight=3)]
|
||||
|
||||
|
@ -239,3 +241,4 @@ Use the `ClientErrorMapping` property to configure the contents of the `ProblemD
|
|||
* <xref:web-api/advanced/formatting>
|
||||
* <xref:tutorials/web-api-help-pages-using-swagger>
|
||||
* <xref:mvc/controllers/routing>
|
||||
****
|
||||
|
|
Loading…
Reference in New Issue