405方法不允许PUT

cod*_*sed 4 asp.net asp.net-web-api

我检查了一切,没有一个配置工作正常.

THE GET,POST正在工作但是我得到了405消息.我没有WebDEV.

这是我的配置.

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV"/>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
      <remove name="OPTIONSVerbHandler"/>
      <remove name="TRACEVerbHandler"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" 
           type="System.Web.Handlers.TransferRequestHandler" 
           preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

它让我疯了!

我已经提到了所有可用的建议,例如: Asp.NET Web API - 405 - 不允许用于访问此页面的HTTP动词 - 如何设置处理程序映射

在此输入图像描述

即使我使用Basic Auth/Windows Auth.禁用它也没有区别.

[System.Web.HttpHttpPut] public override HttpResponseMessage Put(int id,Request entity){....}

注意:我刚刚安装了登台服务器,它已经运行了.但是,它不能在我的机器上工作...... 在此输入图像描述

在此输入图像描述

Kri*_*tof 6

你是否用正确的命名空间用HttpPut修饰了你的动作?应该看起来像这样:

[HttpPut]
public ActionResult ActionName() 
{
  //Your code
}
Run Code Online (Sandbox Code Playgroud)

编辑:显然iis express默认删除并禁用.如果这只发生在iis express中,您可能会发现这个答案很有用.基本上你必须编辑这个文件:

%userprofile%\documents\iisexpress\config\applicationhost.config 
Run Code Online (Sandbox Code Playgroud)

在这一行:

<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
Run Code Online (Sandbox Code Playgroud)

并添加动词PUT

编辑NR 2:
下面这anwser:打开你的IIS管理器,然后选择你的网站.
单击右侧的处理程序映射链接.
找到ExtensionlessUrlHandler-Integrated-4.0条目并双击它.
在Request Restrictions选项卡谓词中,您可以添加put以启用put支持.