I want to pass two params using json in web-api, but I get null each time I try, what am I missing ? is there a better way to pass more than one parameter?
//HTML
var uri = "api/Login";
//after I click a button this function fires
function checkUser() {
var email = "[email protected]";
var password = "itsme";
var details = "{ email:'"+ email+"', pass:'"+ password+"'}";
$.ajax({
type: "Get",
data: JSON.stringify(details),
url: uri,
contentType: "application/json"
});
}
// LoginController
[HttpGet]
public HttpResponseMessage Get([FromBody]string data)
{
HttpResponseMessage msg = null;
//the code run this function, but the 'data' is null
string userinfo = data;
return msg;
}