I want to send data to server using this function:
var _register = function (email, password, passconfirmation) {
var data = {
"Email": email,
"Password": password,
"ConfirmPassword": passconfirmation
};
return $http.post('/api/Account/Register', data, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
}
It doesn't work. My ASP.net web api doesn't receive any data. Every variable on server-side is "null". But when I do this this way:
var _register = function (email, password, passconfirmation) {
var data = "email=" + email + "&password=" + password + "&ConfirmPassword=" + passconfirmation;
return $http.post('/api/Account/Register', data, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
}
Everything works great. The problem is: the first way is much clearer than the second one, so I want to use the first one. But I have no idea what's wrong :/