IIS 10.0详细错误-[httpDelete] [httpPut]的404.0 [英] IIS 10.0 Detailed Error - 404.0 for [httpDelete] [httpPut]
本文介绍了IIS 10.0详细错误-[httpDelete] [httpPut]的404.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在ASP.NET MVC中制作一个api.不幸的是,我遇到了两个HTTP请求的问题:DELETE和PUT
I'm trying to make an api in ASP.NET MVC. Unfortunately I have problem with two HTTP requests: DELETE and 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-未找到.
GET and POST requests are working perfectly fine when I'm trying to sent DELETE OR PUT then browser returns IIS 10.0 Detailed Error - 404.0 - Not Found.
<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中的此更改解决了我的问题
This change in Web.config solve my problem
<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>
这篇关于IIS 10.0详细错误-[httpDelete] [httpPut]的404.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文