問題を解決するにはヘルプが必要です。私の問題は、AngelsからAction MVCへの資格情報を取得している間にうまくいきますが、Viewは他のActionResultにリダイレクトしていません。どうして?ソリューションが必要 これは私のビューです:アクションへのリダイレクト
<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>
これは私の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);
}
});
とMVCアクションは次のとおりです。
[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");
}
あなたのajaxコールから得られる回答は何ですか?それは200 OKですか? – Shyju