问题描述
本地项目ajax请求get post put delete 都正常,部署在iis之后,get post正常,put delete失败,报405(Method not Allowed)
相关代码
function del(id) {
$.ajax({
url: "api/Products/" + id,
type: "Delete",
dataType: "json",
success: function (data) {
location.reload();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest + "," + textStatus + "," + errorThrown);
}
});
}
[HttpDelete]
[ResponseType(typeof(Product))]
public IHttpActionResult DeleteProduct(int id)
{
Product product = db.Product.Find(id);
if (product == null)
{
return NotFound();
}
db.Product.Remove(product);
db.SaveChanges();
return Ok(product);
}
报错详情:
问题已解决。
配置文件移除WebDAV协议