Currently, I am working on an AngularJS project with Web API integration.
One of the controllers I have is called Controller/MasterController, and this is configured in my WebApi Config:
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
To initiate this function, I make a call from Global.asax's Application_Start event.
When calling my web API from service.js, the code looks like this:
var service = function ($http) {
var _$http = $http;
self = this;
self.getMenuItems = function () {
var promise = _$http({
method: "GET",
url: 'api/Master'
}).success(function (data, status, headers, config) {
}).error(function (data, status, headers, config) {
});
return promise;
};
While debugging, I noticed that I reach this particular section. However, the Chrome console displays this error message: "Failed to load resource: the server responded with a status of 404"
The requested URL was:
http://localhost:12345/api/Master
Moreover, attempting to access the web API controller directly through the browser has been unsuccessful for me.
Thank you for your assistance.