Web API - How to validate the model from DataAnnotation.Remote ()?

0

I have the following template (DTO):

public class PessoaAcesso : Pessoa
{
    [Remote("LoginUnico", "Pessoa", ErrorMessage = "Esse Login já existe! Escolha outro.")]
    public virtual string Login { get; set; }
    ...
}

In my ApiController (WebAPI) I implemented the "LoginUnico" method for testing:

public JsonResult<bool> LoginUnico(string login)
{
    return Json(false);
}

However, placing the request via POST is not triggering the method. It was for him to reject the insertion of the new person, but he is accepting.

Anyone who has already implemented Remote () in the WebAPI can guide me.

    
asked by anonymous 14.08.2014 / 22:42

1 answer

1

Note your method with [HttpPost] :

[HttpPost]
public JsonResult<bool> LoginUnico(string login)
{
    return Json(false);
}
    
14.08.2014 / 23:14