TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
boycoto
NA
147
125.2k
[ASP.NET Core+AngularJS] Controller gets NULL value
Jan 13 2017 2:14 AM
I am using VS2015. I am getting error in my controller class (System.NullReferenceException) but in my angularjs I get the value
{"UserName":"admin","UserPassword":"password"}
Hoping you can help me on this. Thanks in Advance.
Below is my controller class:
[HttpPost]
public
JsonResult AuthenticateUser(UserAccessViewModel _users)
{
var users = _context.UserAccess.Where(w => w.Username.Equals(_users.UserName) && w.Userpassword.Equals(_users.UserPassword));
return
Json(users);
}
Controller.js
app.controller(
"MyController"
,
function
($scope, MyService) {
$scope.LoginCheck =
function
() {
$scope.userlogin = {
UserName: $scope.usrName,
UserPassword: $scope.usrPassword
}
var
getData = CartExpressService.UserLogin($scope.UserAccessViewModel);
getData.then(
function
(d) {
$scope.msg = d.data;
alert($scope.msg);
});
debugger
;
}
});
Service.js
app.service(
"MyService"
,
function
($http) {
this
.UserLogin =
function
(user) {
var
response = $http({
method:
"post"
,
url:
"../Administrator/AuthenticateUser"
,
data: JSON.stringify(user),
dataType:
"json"
});
return
response;
}
});
Views
<
div
style
=
"margin-bottom: 25px"
class
=
"input-group"
>
<
span
class
=
"input-group-addon"
>
<
i
class
=
"glyphicon glyphicon-user"
>
i
>
span
>
<
input
type
=
"text"
class
=
"form-control"
ng-model
=
"UserAccessViewModel.UserName"
placeholder
=
"Username"
>
div
>
<
div
style
=
"margin-bottom: 25px"
class
=
"input-group"
>
<
span
class
=
"input-group-addon"
>
<
i
class
=
"glyphicon glyphicon-lock"
>
i
>
span
>
<
input
type
=
"password"
class
=
"form-control"
ng-model
=
"UserAccessViewModel.UserPassword"
placeholder
=
"Password"
>
div
>
<
div
style
=
"margin-top:10px"
class
=
"form-group"
>
<
div
class
=
"col-sm-12 controls"
>
<
a
id
=
"btn-login"
href
=
"#"
class
=
"btn btn-success"
ng-click
=
"LoginCheck()"
>
Login
a
>
div
>
div
>
form
>
Error:
Reply
Answers (
1
)
AES Encrypt Decrypt
Webapi wit angular