I'm trying to send a http post request from angular client to C# web API 2 RESTful web service.
My client:
var userId = "123456";
var password = "654321";
const headersContent = new Headers().set('Content-Type', 'application/x-www-form-urlencoded');
var url = "http://localhost:35615/login"
this.http.post(url, {
"userId": userId,
"password": password
}, {withCredentials: true}).subscribe(res => {
console.log(res);
});
My Server:
[Route("login")]
[HttpPost]
public IHttpActionResult LoginReq([FromBody] string parameters)
{
//Deserialize the parameters.
}
My problem is the parameters var is null although the post request in the network tab in chrome includes the data.
Can someone explain me what I'm doing wrong and how can I fix it? Thank you!