webapi 405 method not allowed

问题的原因:创建webapi controller时,习惯创建了mvc的controller,而非api controller。导致引用包有问题。


这两天搞webapi开发的时候,遇见了405错误。

我贴一下解决的方式:


controller中添加如下引用。

using System.Net;
using System.Net.Http;
using System.Web.Http;

删除

using System.Web.Mvc;

Action头部添加相应的请求方式

[HttpPost]
[HttpGet]
........



posted @ 2016-11-30 10:22  正怒月神  阅读(800)  评论(0编辑  收藏  举报