San*_*ndo 6 iis-7 asp.net-web-api
使用Windows 2008 Server IIS 时,我遇到500-内部服务器错误PUT/DELETE。我得到的答复是:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
Formatting
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>500 - Internal server error.</h2>
<h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
</fieldset></div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我查看我的WebAPI的自定义日志时,我发现该呼叫甚至没有打到该服务。
我以往的经验是越来越404 -找不到了PUT和DELETE而这种行为是跨越的Win7和Win 2008服务器是一致的。为此,我找到了此修复程序:
我应用了此修复程序,并PUT/DELETE在Windows 7上运行。但是在那之后,当在win2008服务器的IIS 7上部署相同的服务时,我没有得到400。但是我从IIS或什至之前得到了“ 500-Internal Server Error”。
相同的代码可在Windows 7(IIS 7.5)上完美运行。
关于解决此类问题的任何线索?
编辑于2012年8月29日:
通过在IIS7中启用故障跟踪可以检测到500-内部服务器错误的问题。解决方法是此配置。
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
Run Code Online (Sandbox Code Playgroud)
基本上,我们需要从模块中删除“ WebDAVModule”,也需要从处理程序中删除“ WebDAV”。但是现在,我又回到了旧版的404-Not Found。现在,即使具有以下配置,我也无法执行PUT / DELETE:
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
Run Code Online (Sandbox Code Playgroud)
通常,同一Web应用程序可以完美地在同一系统的同一IIS上单独托管(不在默认Web站点下)。所以我怀疑这是由于某些父网站配置过滤了PUT / DELETE请求。
有相同的想法吗?
在苦恼了一个非常相似的问题之后,我找到了这个解决方案: http://www.iis.net/configreference/system.webserver/security/requestfiltering/verbs
使用请求过滤设置,我能够在 IIS 中全局允许 PUT 和 DELETE 动词,这解决了我的问题。它结束了我 404.6 错误的噩梦。(顺便说一句,我没有安装 webDAV 并将动词添加到 ExtensionlessUrlHandler)
希望此信息可以节省某人一些时间。
| 归档时间: |
|
| 查看次数: |
8191 次 |
| 最近记录: |