asp.net-mvc – 405消息,Web Api不允许的方法

我在API控制器上有以下内容
public void UpdateClient(Client client)
    {
        try
        {
            if (ModelState.IsValid)
            {
                db.Entry(client).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
        catch
        {
            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
    }

并在页面上的以下内容

$.ajax({
            url: "api/client/UpdateClient",type: "PUT",contentType: 'json',data: ko.toJSON(model.selectedClient()),success: function (result) {
                getClients();
                $("#loader").hide();
            },failure: function (result) {
                alert(result.d);
                $("#loader").hide();
            },error: function (XMLHttpRequest,textStatus,errorThrown) {
                alert("An error occurred,please try again.");
                $("#loader").hide();
            }
        });

但是这会给出错误405方法不允许,任何人都可以看到我可能出错了吗?为了参考,api的url可以,因为我使用相同的api控制器来做其他的功能

此外,selectedClient()是通过WebApi接收的客户端对象,所以应该完全匹配PUT再次。

解决方法

如果您使用IIS7并安装了WebDav,请尝试将其删除
我只是用PUT动词得到相同的错误解决了这个问题

更新:您可以在这里阅读WebDav:http://www.iis.net/learn/get-started/whats-new-in-iis-7/what39s-new-for-webdav-and-iis-7

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...