I have an MVC app using AngularJS. We do not use WebAPI. So, the angularJS would just be calling the MVC Controllers. These calls work fine in IE & Chrome. However, in Firefox and Safari I tried for hours to get it up and running without any result. As you can see in the code below, I do have a LoginController.js file and LoginService.js file. The service.js file returns a promise object back to the controller. In firefox on error the data is null, headers are emptry, statusText is empty and status is -1. I do not see if this has anything to do with CORS. But I do not have any cors going on in here as the service just calls the MVC Controller.
LoginController.JS file
app.controller('LoginController',
function ($scope, LoginService) {
$scope.schoolList = null;
$scope.SelectedDistrictId = null;
$scope.isFLUser = $("#isFLUser").val();
$scope.User =
{
userName: "",
password: "",
Email: null,
firstName: "",
lastName: "",
roleId: null,
districtId: null,
schoolId: null,
districtName: "",
schoolName: "",
isFL: $("#IsFL").val()
}
$scope.validateUser = function () {
$("#LoginErrorSpan").hide();
var form = $('form');
$.validator.unobtrusive.parse(form);
if (form.valid()) {
$("#spinnerdiv").show();
debugger;
var promise = LoginService.validateUser($scope.User);
promise.then(function (result) {
debugger;
$("#spinnerdiv").hide();
if (result.data.InvalidUser === false) {
if (result.data.PwdchangeCount > 0) {
window.location.href = "/Login/Welcome";
}
else {
window.location.href = "/Login/ChangePassword";
}
} else {
$("#LoginErrorSpan").show();
}
},
function (result) {
debugger;
console.log(result.headers());
});
}
}
});
LoginService.JS File
var app = angular.module('app', []);
app.factory('LoginService',
function ($http) {
return {
validateUser: function (scopeUser) {
return $http({
url: "/Login/ValidateUser",
method: "GET",
params: {
userName: scopeUser.userName,
//password: encodeURIComponent(scopeUser.password),
password: scopeUser.password,
isFL: scopeUser.isFL
}
});
}
}
});
I have been trying to debug this for the last 8 hours with all the solutions I could find online.