我见过吨关于这个职位,但我的新的WebAPI DELETE方法根本不起作用,并返回404,使用Windows 7 32位,IIS 7.5。
我试过
卸载的WebDAV 添加PUT,DELETE,OPTIONS到ExtensionlessUrlHandler集成-4.0处理器(32位和/ 64bit的处理程序)。 允许所有模块运行。所有无果而所有404。如果我改变DELETE类型为GET,则该服务运行GET命令完全正常的。
任何人只要有这方面有任何其他的想法?它的驾驶我疯了。
编辑:
我打电话DELETE方法是这样的(调停是围绕jQuery的调用的包装):
mediator.publish(AjaxCall的,{
网址:/ API /文件/+ $(a.currentTarget)的.data(FILEID),
键入:删除,
}
});
和的WebAPI:
//删除API /<控制器> / 5
// [HttpDelete] - 尝试这样做太
公共无效删除(INT FILEID)
{
Files.DeleteFile(FILEID);
}
和相关的web.config:
<处理>
<删除名称=ExtensionlessUrlHandler-ISAPI-4.0_32bit/>
<删除名称=ExtensionlessUrlHandler-ISAPI-4.0_64bit/>
<删除名称=ExtensionlessUrlHandler集成-4.0/>
<添加名称=ExtensionlessUrlHandler-ISAPI-4.0_32bit路径=*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS模块=IsapiModulescriptProcessor =%WINDIR%\ Microsoft.NET \框架\ v4.0.30319 \ aspnet_isapi.dll的preCondition = classicMode,runtimeVersionv4.0,bitness32responseBufferLimit =0/>
<添加名称=ExtensionlessUrlHandler-ISAPI-4.0_64bit路径=*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS模块=IsapiModulescriptProcessor =%WINDIR%\ Microsoft.NET \ Framework64 \ v4.0.30319 \ aspnet_isapi.dll的preCondition = classicMode,runtimeVersionv4.0,bitness64responseBufferLimit =0/>
<添加名称=ExtensionlessUrlHandler集成-4.0路径=*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONSTYPE =System.Web.Handlers.TransferRequestHandlerpreCondition =integratedMode,runtimeVersionv4.0/>
< /处理器>
<模块runAllManagedModulesForAllRequests =真正的>
<删除名称=WebDAVModule/>
< /模块>
解决方案
该解决方案是增加PUT和放大器;在正确的applicationHost.config文件删除动词。
有关IIS:
转到lcation:C:\ WINDOWS \ SYSTEM32 \ INETSRV \ CONFIG 和编辑applicationHost.config文件为:
<添加名称=ExtensionlessUrlHandler-ISAPI-4.0_32bit路径=*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS模块=IsapiModulescriptProcessor =%WINDIR%\ Microsoft.NET \框架\ v4.0.30319 \ aspnet_isapi.dll的preCondition = classicMode,runtimeVersionv4.0,bitness32responseBufferLimit =0/>
<添加名称=ExtensionlessUrlHandler-ISAPI-4.0_64bit路径=*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS模块=IsapiModulescriptProcessor =%WINDIR%\ Microsoft.NET \ Framework64 \ v4.0.30319 \ aspnet_isapi.dll的preCondition = classicMode,runtimeVersionv4.0,bitness64responseBufferLimit =0/>
<添加名称=ExtensionlessUrlHandler集成-4.0路径=*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONSTYPE =System.Web.Handlers.TransferRequestHandlerpreCondition =integratedMode,runtimeVersionv4.0/>
有关IIS EX $ P $干燥综合征GO TO: %USERPROFILE%\文档\ iisex preSS \设置\ 并做好applicationHost.config文件相同。
I've seen tons of posts about this, but the DELETE method of my new WebAPI simply does not work and returns a 404, using Windows 7 32-bit, IIS 7.5.
I've tried
Uninstalling WebDAV Adding PUT, DELETE, OPTIONS to the ExtensionlessUrlHandler-Integrated-4.0 handler (and 32bit/64bit handlers). Allowing all modules to run.All to no avail and all return 404. If I change the DELETE type to a GET, then the service runs the GET command perfectly fine.
Anyone with any other ideas about this? It's driving me crazy.
EDIT:
I'm calling the DELETE method like this (mediator is a wrapper around the jQuery call):
mediator.publish("AjaxCall", {
url: "/api/files/" + $(a.currentTarget).data("fileid"),
type: "DELETE",
}
});
And WebAPI:
// DELETE api/<controller>/5
// [HttpDelete] - Tried this too
public void Delete(int fileId)
{
Files.DeleteFile(fileId);
}
And relevant web.config:
<handlers>
<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" />
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
解决方案
The Solution is to add PUT & DELETE verb in correct applicationHost.config file.
For IIS :
Go to lcation: C:\Windows\System32\inetsrv\config and edit the applicationHost.config file as:
<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" />
For IIS EXPRESS GO TO : %userprofile%\documents\iisexpress\config\ and do the same in applicationHost.config file.