I am trying to call a web api service from a mvc client. After several errors that I've managed to solve, I am stuck on: "Failed to load resource: the server responded with a status of 404 (Not Found)".
My routing:
routes.MapRoute(
name: "Default",
url: "{controller}/**{action}**/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
The web api:
public class TestServicesController : ApiController
{
[HttpGet]
public HttpResponseMessage GetTest()
{
Console.Write("SUCCESS!!!!!");
return Request.CreateResponse(HttpStatusCode.OK);
}
}
the client:
function test1() {
$.ajax({
url: "http://localhost:52285/api/Services/GetTest",
type: 'GET',
success: function () { alert("success!!"); },
});
}
I have tried searching for that problem, nothing worked.. please help!