in the Models folder there is such a simple model:
public class User { public int Id { get; set; } public string Name { get; set; } public string Email { get; set; } } In the UserController controller that processes the request, the following code is written:
public class UserController : Controller { // PUT: /User/Edit [HttpPut] public JsonResult Edit(int id, User user) { System.Diagnostics.Debug.WriteLine("Put request is working"); //не выполняется return Json("Response from Edit"); } } And sending the request from the Index.cshtml file
/*PUT*/ $.ajax({ url: '/User/Edit', dataType: "json", type: "PUT", contentType: 'application/json; charset=utf-8', data: JSON.stringify({ id: 100, user: { name: 'Dmitry', email: 'dmitry@gmail.com' } }), async: true, processData: false, cache: false, success: function (data) { alert(data); //это не работает }, error: function (xhr) { alert('error'); //срабатывает эта строка } });