I'm doing my first angularsjs-asp.net web api project. I am trying to send a $scope.user object to asp.net web api as follows-
AngularJS controller code-
$scope.user = {};
$scope.navbarCollapsed = true;
$scope.save = function () {
$http.get('/api/Login', $scope.user).
success(function (data, status, headers, config) {
$window.location.href = 'app/views/dashboard.html';
}).
error(function (data, status, headers, config) {
alert(status);
});
}
ASP.NET web API code:
public class LoginController : ApiController
{
public HttpResponseMessage get( LoginUser user) //user is shown null
{
}
}
user is shown null in server side. Any help?
UPDATE----------------
public class LoginUser
{
public String LoginName { get; set; }
public String LoginPassword { get; set; }
}
$scope.userhas? What fieldsLoginUserhas ?POSTmethod.