I have this code:
$.ajax({
type: \"POST\",
url: \"/api/slide\",
cache: false,
contentType: \"application/json; charset=u
Define a view model:
public class SlideViewModel
{
public string Title { get; set; }
}
then have your controller action take this view model as argument:
public class SlideController : ApiController
{
// POST /api/Slide
public void Post(SlideViewModel model)
{
...
}
}
finally invoke the action:
$.ajax({
type: 'POST',
url: '/api/slide',
cache: false,
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({ title: "fghfdhgfdgfd" }),
success: function() {
...
}
});
The reason for that is that simple types such as strings are bound from the URI. I also invite you to read the following article about model binding in the Web API.