So I'm, making a call to a web api controller fro within the same mvc app as m angular code, like so
$http.get('/api/lime/').success(function (data) {
$scope.line = data;
$scope.$apply();
}).error(function (jqXhr, status, errorThrown) {
//$('#lblMessage').text(errorThrown).show();
});
It works fine, and actually hits the break point in the class the the web api actually uses to get the data, but it won't hit the controller. T'm not passing an id, so it's hitting the second httpget that doesn't take a parameter. The controller is below. Note: The LimeLoader().GetLimes() line is a call to a class in the solution that pulls in the data. I have a breakpoint in this class and it reaches it fine.
public class LimeController : ApiController
{
[HttpGet]
public LimeLoader GetLime(int id)
{
return new LimeLoader(id);
}
[HttpGet]
public IEnumerable<LimeLoader> GetLimes()
{
return new LimeLoader().GetLimes().ToList();
}
}
Here's the route:
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
It returns the collection from the second HttpGet method, but why isn't is hitting my breakpoint in controller? Thanks in advance.