gpt4 book ai didi

asp.net-mvc - IIS 10.0 详细错误 - [httpDelete] [httpPut] 的 404.0

转载 作者:行者123 更新时间:2023-12-03 07:06:39 28 4
gpt4 key购买 nike

我正在尝试在 ASP.NET MVC 中创建一个 api。不幸的是,我遇到了两个 HTTP 请求的问题:DELETE 和 PUT

    [ActionName("Index")]
[HttpGet]
public String Index()
{
return "get";
}

[ActionName("Index")]
[HttpPost]
public String IndexPost()
{
return "create";
}


[ActionName("Index")]
[HttpPut]
public String IndexPut()
{
return "update";
}
[ActionName("Index")]
[HttpDelete]
public String IndexDelete()
{
return "delete";
}

当我尝试发送 DELETE 或 PUT 时,GET 和 POST 请求工作得很好,然后浏览器返回 IIS 10.0 详细错误 - 404.0 - 未找到。

<system.webServer>
<modules>
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrl-Integrated-4.0" />
<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,DELETE,PUT" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

最佳答案

Web.config 中的此更改解决了我的问题

 <handlers>
<remove name="WebDAV"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="OPTIONSVerbHandler" path="*" verb="OPTIONS" modules="ProtocolSupportModule" requireAccess="None" responseBufferLimit="4194304" />
</handlers>

关于asp.net-mvc - IIS 10.0 详细错误 - [httpDelete] [httpPut] 的 404.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40563584/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com