Specifies that a parameter of a controller method will receive the value of a field, obtained by deserializing a request URL query.
The parameter carrying this attribute can be either a simple type or a one-dimension array.
If multiple values are present for the field, a non-array parameter will receive the last specified value, while an array parameter will receive an array of field values converted to the element type of the parameter.
If a single value is present for the field, a non-array parameter will receive the value converted to the type of the parameter, while an array parameter will receive an array of length 1, containing the value converted to the element type of the parameter
If no values are present for the field and the BadRequestIfMissing property is true, a 400 Bad Request
response will be sent to the client, with a message specifying the name of the missing field.
If no values are present for the field and the BadRequestIfMissing property is false, a non-array parameter will receive the default value for its type, while an array parameter will receive an array of length 0.
This class cannot be inherited.
InheritanceQueryFieldAttribute
Namespace: EmbedIO.WebApi Syntaxpublic sealed class QueryFieldAttribute : Attribute, IRequestDataAttribute<WebApiController, string>, INonNullRequestDataAttribute<WebApiController, string[]>, IRequestDataAttribute<WebApiController>
Constructors QueryFieldAttribute()
Initializes a new instance of the QueryFieldAttribute class. The name of the query field to extract will be equal to the name of the parameter carrying this attribute.
Declarationpublic QueryFieldAttribute()
QueryFieldAttribute(Boolean)
Initializes a new instance of the QueryFieldAttribute class. The name of the query field to extract will be equal to the name of the parameter carrying this attribute.
Declarationpublic QueryFieldAttribute(bool badRequestIfMissing)
Parameters Type Name Description Boolean badRequestIfMissing
If set to true, a 400 Bad Request
response will be sent to the client if no values are found for the field; if set to false, a default value will be assumed.
Initializes a new instance of the QueryFieldAttribute class.
Declarationpublic QueryFieldAttribute(string fieldName)
Parameters Type Name Description String fieldName
The name of the query field to extract.
QueryFieldAttribute(String, Boolean)Initializes a new instance of the QueryFieldAttribute class.
Declarationpublic QueryFieldAttribute(string fieldName, bool badRequestIfMissing)
Parameters Type Name Description String fieldName
The name of the query field to extract.
Boolean badRequestIfMissingIf set to true, a 400 Bad Request
response will be sent to the client if no values are found for the field; if set to false, a default value will be assumed.
Gets or sets a value indicating whether to send a 400 Bad Request
response to the client if the URL query contains no values for the field.
If this property is true and the URL query contains no values for the field, the 400 Bad Request
response sent to the client will contain a reference to the missing field.
If this property is false and the URL query contains no values for the field, the default value for the parameter (or a zero-length array if the parameter is of an array type) will be passed to the controller method.
Declarationpublic bool BadRequestIfMissing { get; }
Property Value FieldName
Gets the name of the query field that this attribute will extract, or null if the name of the parameter carrying this attribute is to be used as field name.
Declarationpublic string FieldName { get; }
Property Value Explicit Interface Implementations INonNullRequestDataAttribute<WebApiController, String[]>.GetRequestDataAsync(WebApiController, String) Declaration
Task<string[]> INonNullRequestDataAttribute<WebApiController, string[]>.GetRequestDataAsync(WebApiController controller, string parameterName)
Parameters Returns Type Description Task<String[]> IRequestDataAttribute<WebApiController, String>.GetRequestDataAsync(WebApiController, String) Declaration
Task<string> IRequestDataAttribute<WebApiController, string>.GetRequestDataAsync(WebApiController controller, string parameterName)
Parameters Returns IRequestDataAttribute<WebApiController>.GetRequestDataAsync(WebApiController, Type, String) Declaration
Task<object> IRequestDataAttribute<WebApiController>.GetRequestDataAsync(WebApiController controller, Type type, string parameterName)
Parameters Returns Implements See Also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4