Brauchen Sie Hilfe in folgenden Problem. Mein Problem ist, während ich die Berechtigung von angularjs zu Action MVC bekomme, funktioniert es gut, aber View leitet nicht zum anderen ActionResult um. Warum? brauchen Lösung Das ist meine Ansicht:Umleitung zu Aktion
<body ng-app="LoginModule">
<div id="body" ng-controller="LoginController">
<div>``
<div>
<label id="labels">User Name:</label> <input type="text" ng-model="User.UserName" />
<br />
<label id="labels">Password: </label> <input type="password" ng-model="User.UserPassword" />
<br />
<input id="buttons" class="btn btn-primary" value="Login" type="button" ng-click="Login()" />
</div>
</div>
</div>
Dies ist mein js:
var loginModuel = angular.module("LoginModule", [])
loginModuel.controller("LoginController", function ($scope, $http) {
alert("LoginController");
$scope.Login = function()
{
alert("Login Function");
var result = $http({ method: 'POST', url: '/Home/Login', params: { user: $scope.User } });
result.success((function() {
window.location.href = '/Doctor/DoctorPanel';
}));
alert($scope.User.UserName + "-" + $scope.User.UserPassword);
}
});
und MVC Aktion ist:
[HttpPost]
public ActionResult Login()
{
JObject json = JObject.Parse(Request["user"]);
string userName = (string)json["UserName"];
string userPass = (string)json["UserPassword"];
User u = New User();
u.User_Name = "Test";
u.User_Password ="ABCD";
if (u.Users_Name == userName && u.Users_Password == userPass)
{
return View("WelcomUser","Home");
}
return View("Index","Home");
}
Wie lautet die Antwort, die Sie von Ihrem Ajax-Anruf erhalten? ist das ein 200 ok? – Shyju