In my WebApi i have single controller + single method.
[RoutePrefix("References")]
public class ReferencesController : ApiController
{
[HttpPost]
[Route("MyTypes")]
public List<MyTypeModel> MyTypes([FromBody]string value) // value == null
{ /// }
}
I make this request to server (using postman):
POST /References/MyTypes/ HTTP/1.1
Host: localhost:59640
Content-Type: application/x-www-form-urlencoded
cache-control: no-cache
Postman-Token: 9c44b544-53dc-43a8-8e2a-1b63fe4bf591
value=testvalueundefined=undefined
Why "value" in my controller is null ?
And why this works well if i replace type of "value" from string to any Class type:
[HttpPost]
[Route("MyTypes")]
public List<MyTypeModel> MyTypes([FromBody]MyClass value) // value != null
{ /// }
POST /References/MyTypes/ HTTP/1.1
Host: localhost:59640
Content-Type: application/x-www-form-urlencoded
cache-control: no-cache
Postman-Token: 29b606d4-8d42-4790-a03b-e4e170b91a9b
Host=127.0.0.1UserName=wfPassword=123456undefined=undefined
How it works ?
Comments
Post a Comment