Я занимаюсь разработкой asp. net веб-API-интерфейса, но не могу получить запрос "PUT" в Jquery для работы. Я перепробовал все, что написано на эту тему, но пока не повезло.
function insertstopcode(id) {
var insert = {};
insert.stopcause = $("#DropDownList4").val();
insert.id = $("#DropDownList5").val();
alert(insert.id)
alert(insert.stopcause)
$.ajax({
type:'PUT',
url: 'http://localhost:52059/api/stop/'+insert.id,
dataType: 'JSON',
data: JSON.stringify(insert),
contentType: "Application/json;charset=utf-8",
succes: function (data) {
alert('Stopcode er registreret..')
}
})
}
Мой контроллер выглядит так:
[HttpPut]
[Route("api/stop/{id:int}")]
public IHttpActionResult Put(int id)
{
using (testdatabseEntities1 nd = new testdatabseEntities1())
{
var bb = nd.BI_table.FirstOrDefault(x => x.id == id);
return Ok(bb);
}
}