I have created a solution with the following project
FrontEnd is a mvc4 web application and MyWebAPI is a mvc4 webAPI
I want to be able to access MyWebAPI control methods from my FrontEnd project. But it doesn't work as it only complains that data couldn't be found when I run the webAPI urls.
Do I have to do something more so my FrontEnd can talk to MyWebAPI?
For example I simply just tried to run this pre generated webAPI control method
public string Get(int id)
{
return "value";
}
It could not be found. However if I change the startup project to be MyWebAPI then it works. So my question is how to make it so I can access MyWebAPI from my FrontEnd project?
This question is actually same as this one but it doesn't explain how I can access the webAPI from the frontend when they are within the same solution
EDIT
$(document).ready(function() {
$("#clickMe").click(function() {
var id = $("#dataBox").val();
$.ajax({
url: "http://localhost:11982/api/Movie/GetMovie",
data: { id: id },
type: "get",
contentType: "application/json;charset=utf-8",
success: function(data) {
alert(data);
},
error: function(jqXHR, status, errorThrown) {
// alert("Error " + status + "\nError Thrown" + errorThrown + "\n" + jqXHR )
}
})
})
})
UPDATED 2012-08-30
I updated different packages in my solution, amongst them WebAPI beta to WebAPI rc version. And now for some reason when I send a form request or ajax request to any of the WebAPI controller, it will for the form request response saying that no such controller was found, and for for the ajax request it will load forever without returning a response.
Anyone who experience similar problem before?
Previous solution to it was to run my FrontEnd and MyWebAPI in local IIS server. However it stopped to work now since I updated all the packages.