简体   繁体   中英

Failed to load resource: the server responded with a status of 404 angularjs

I am new in angular Other Binding is working fine but $https call is not working I got error like this when I call http call

Failed to load resource: the server responded with a status of 404 (Not Found) My Script Code is

(function(angular) {
   var myApp = angular.module("myApp", []);
   myApp.controller('myTestController', function($scope, $http) {
     $scope.firstName = "Test";
     $http.get("Students/GetStudents").success(function(response) {
       $scope.firstName = response;
     });
   });
 })(window.angular); 

My API Controller is:

[HttpGet]
public string GetStudents() {
    return "My Value";
}

In Api Controller: [HttpGet] [Route("getStudents")] public string GetStudents() { return "My Value"; } [HttpGet] [Route("getStudents")] public string GetStudents() { return "My Value"; }

And in angular: change "Students/GetStudents" for "Students/getStudents"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM