问题的原因:创建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]
........



相关文章:

  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
相关资源
相似解决方案