lundi 23 janvier 2017

Unable to call web api methods

Hi I am developing small application in web api2 with angularjs. I have one controller called UsersController with index action method and index view. I am using angularjs. Inside script folder i have one more folder users with three files modules.js,controller.js and service.js. Also i have one more web api controller called TestController with all http methods inside. I am calling test controller as below using angularjs. In index.cshtml i have form to submit simple data.

this.saveUsers = function (users) {
        return $http({
            method: 'post',
            data: users,
            url: "/api/Test",
            contentType: "application/json"
        });
    }

When i click on submit button i am getting error message as below.

http://localhost:22499/Users/api/Test

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

n my url I am getting Users(Controllername MVC). I am not sure why it is not calling and May i know is this is the reason that i am not able to call any http methods? Any help would be appreciated. Thank you.




Aucun commentaire:

Enregistrer un commentaire