I am trying to navigating from login page to Home page but it is not navigating to login page even though it is hitting HomeController, here i used angularjs http.get service for navigating.
I have verified RouteConfig settings, but am unable to find the problem where it is.
Below is route config
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
angular code
(function () {
var app = angular.module("AngularApp", []);
app.service("loginservice", function ($http) {
this.Checkuser = function (UserName, password) {
return $http({
method: "Post",
url: "Login/LoginUserAuth/",
data: { UserName: UserName, password: password }
});
}
this.NavigateToHome = function (UserName) {
return $http({
method: "get",
url: "Home/Index"
});
}
});
app.controller("LoginController", function ($scope, $http, loginservice) {
$scope.Checkuser = function () {
var checkresult = loginservice.Checkuser($scope.username, $scope.password);
checkresult.success(function (dataFromServer, status, headers, config) {
//alert(dataFromServer);
if (dataFromServer == '"Login Success"') {
var NavigateToHome = loginservice.NavigateToHome($scope.username);
}
else {
alert('Wrong UserName or Password');
}
});
checkresult.error(function () {
alert('Error in Login');
});
}
});
}
())
Home controller
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
return View();
}
}