I\'ve checked a few similar questions, but none of the answers seem to fit (or dumb it down enough for me). So, I have a really simple WebAPI to check if user with an email
Either change it to a POST to send the object you are trying to send through the request body or change you method signature to accept the email address.
var param = { "email": "ex.ample@email.com" };
$.ajax({
url: "/api/users/" + param.email,
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data == true) {
// notify user that email exists
}
else {
// not taken
}
}
});
[HttpGet, Route("api/users/{emailaddress}")]
public bool Get(string emailaddress)
{
string email = emailaddress;
UserStore userStore = new UserStore();
ApplicationUserManager manager = new ApplicationUserManager(userStore);
ApplicationUser user = manager.FindByEmail(email);
if (user != null)
{
return true;
}
else
{
return false;
}
}
//helper class:
public class UserResponse
{
public string email { get; set; }
}