I have developed a .Net Webapi which uses Entity Framework and all is functioning correctly using the uri... //mywebserver/webappfolder/api/mycontroller?val=1&val=2&val=3
The EF and API are in the same project.
With no custom client application necessary at this point, entering this uri into my local PC browser I get the JSON or XML results as expected. So I assumed I could start writing a client to consume the WebAPI on my development box and run it on "//mydeveloperserver/..."
$(document).ready(function () {
$('#button').click(function () {
alert('Hello. This works');
$.get('http://mywebserver/webappfolder/api/mycontroller', function (data) {
$.each(data, function (n, val) {
$('#OutputDiv').add(n + ':Dedication ' + val.DedicationName);
});
});
});
});
The JQuery/AJAX was not able to fill the results of the callback function even though I could see the request successfully being made and returned using Fiddler.
After digging through documentation I realized the client consuming app had to run on the same web server "//mywebserver/..." as the WebAPI and once the JQuery/AJAX client web app was moved to "mywebserver" the callback function populated the JSON results as expected. The above code now works
We have website apps on other servers and .Net Windows Forms apps that I want to use to call the WebAPI and consume that data without compromising security. How do I call the WebAPI running on my production server from my developer box web applications. Do I need to have another layer of code on the WebAPI server to allow me to consume that data from elsewhere?