How would I call an ASP.NET Web API directly from code-behind? Or should I be calling my javascript function that calls the getJSON method from code-behind?
I usually have something like:
function createFile() {
$.getJSON("api/file/createfile",
function (data) {
$("#Result").append('Success!');
});
}
Any pointers appreciated. TIA.
*I’m using WebForms.
If you must call the web service itself, you can try using
HttpClientas described by Henrik Neilsen.Updated HTTPClient Samples
A basic example: