Asp.net web api for serving [FromBody] and [FromUri] and when there is a real need to use?
example:
public IHttpActionResult Get([FromUri] email)
{
}
public IHttpActionResult Get([FromBody] email)
{
}
Asp.net web api for serving [FromBody] and [FromUri] and when there is a real need to use?
example:
public IHttpActionResult Get([FromUri] email)
{
}
public IHttpActionResult Get([FromBody] email)
{
}
There are two attributes for you to make explicit what parameter binding your API will use. By default, the framework will map almost all objects as a JSON that comes in the body of the request (DateTime, Guid, are examples of objects it will try to get from the URI), and any simple / primitive type as a value that will come in Request URI. So if you want to do the reverse, you need to specify where the request is coming from.
Example, if you want to receive a string that comes in the body of your request, you must specify for the API: public IHttpActionResult GetPessoaPorNome([FromBody] string pessoa) {}