大佬教程收集整理的这篇文章主要介绍了asp.net-mvc – 405消息,Web 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再次。
更新:您可以在这里阅读WebDav:http://www.iis.net/learn/get-started/whats-new-in-iis-7/what39s-new-for-webdav-and-iis-7
以上是大佬教程为你收集整理的asp.net-mvc – 405消息,Web Api不允许的方法全部内容,希望文章能够帮你解决asp.net-mvc – 405消息,Web Api不允许的方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。