This might be basic question but I couldn\'t find where the issue is. I am using .Net Core for by back end and angularJS for front end. below is my code.
<
You have to use the [FromBody]
attribute with a model parameter.
public class Credentials
{
public string Email { get; set; }
public string Password { get; set; }
}
public IActionResult Login([FromBody]Credentials creds)
{
// do stuff
}
This is because in ASP.NET Core MVC the default content type is application/x-www-form-urlencoded
(for handling HTML form data). The [FromBody]
attribute tells the model binder to instead try and create the model from JSON content.