HttpPut和HttpDelete没有被称为部署在本地IIS的ASP.NET WebAPI

问题描述 投票:0回答:1

无法从POSTMan客户端调用HttpPut和HttpDelete方法到ASP.NET WebAPI下面是代码和web.config条目。我在我的本地IIS上运行WEBAPI。 HttpPost和HttpGet方法有效。

enter image description here

从POSTMan客户端运行代码时抛出404错误。 enter image description here

enter image description here

Web.Config值enter image description here

enter image description here

iis web-config asp.net-web-api2 postman http-put
1个回答
1
投票

你调用PUT方法的方式是错误的。

将方法的原型更改为:

[HttpPut]
[Route("update/{cKey}"]
public HttpResponseMessage Put(int cKey)

在那之后,你在邮递员的电话应该工作。

您定义路线的方式不正确,因为cKey变量永远不会被映射。由于您的方法接受不可为空的整数,因此必须在查询字符串中提供它。因此,对update?valQuestionPayload=123的请求也将起作用。

© www.soinside.com 2019 - 2024. All rights reserved.