I have a PHP program POSTING to a C# MVC WebApi. The WebApi program starts as:
public async Task<IHttpActionResult> EmailExists(UsersEmailExistsBindingModel model)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
/* remaining functionality */
}
The binding model as as follows:
public class UsersEmailExistsBindingModel
{
[Required]
public string UserId { get; set; }
[Required]
public string Email { get; set; }
public bool Update { get; set; }
}
The Update property represents if this is for an existing user or not. i.e Are we doing an update?
When PHP posts the request, it uses Update=1 in the form content, which returns The value '1' is not valid for Update
.
How can I specify that 1 and 0 should be accepted as valid values for true and false for the boolean value when binding?