I am unable to post data from view page to Wep Api MVC 4 . My Application and Web Api both are different project.
Given below is my jquery ajax call:
$.ajax({
url: 'http://localhost/api/Contacts',
type: 'POST',
value: 'newcontact',
dataType: 'jsonp',
success: function (result) {
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
alert(errorThrown);
}
});
I want to post data from jquery call to below controller method
// POST api/contacts
public void Post([FromBody]string value)
{
}
Please I am not using models to store data in view page and retrieve them in controller method because both are different project. Moreover its a simple html page in my MVC Project. So Please tell me where I made mistake and tell how to post data from page to Web Api MVC 4?