简体   繁体   English

WEB API DELETE请求导致内部服务器错误500,内容长度为0

[英]WEB API DELETE request causes internal server error 500 with 0 length content

I have created a Microsoft Web API with a number of controllers. 我创建了一个带有多个控制器的Microsoft Web API。 On my local machine (Win 7, IIS Express) testing one of the controllers everything works fine. 在我的本地计算机(Win 7,IIS Express)上测试其中一个控制器,一切正常。 I can delete a "make" object with id 1 using the request localhostetc/makes/1. 我可以使用localhostetc / makes / 1请求删除ID为1的“ make”对象。 When I deploy to the server (W2K8, IIS7.5) I get a 500 error on the same request - see http://api.carsnow.ie/makes/1 当我部署到服务器(W2K8,IIS7.5)时,在同一请求上出现500错误-请参阅http://api.carsnow.ie/makes/1

My question is not what is causing the error, but what is the error? 我的问题不是导致错误的原因,而是错误是什么? I can't see the details as I get a 0 length response. 收到0长度的回复时,我看不到详细信息。 Earlier I was getting a custom error but at some stage when trying to see the underlying stack trace I lost even that. 早些时候,我遇到了一个自定义错误,但是在尝试查看基础堆栈跟踪的某个阶段,我什至丢失了该错误。

So far I have tried the following.... 到目前为止,我已经尝试了以下方法。

I turned CustomErrors to "Off" in web.config 我在web.config中将CustomErrors设置为“关闭”

I added this code to WebAPIConfig.cs - http://lostechies.com/jimmybogard/2012/04/18/custom-errors-and-error-detail-policy-in-asp-net-web-api/ 我将此代码添加到了WebAPIConfig.cs- http: //lostechies.com/jimmybogard/2012/04/18/custom-errors-and-error-detail-policy-in-asp-net-web-api/

I added 我加了

GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; 

to Global.asax 到Global.asax

I turned on detailed errors in IIS7 我打开了IIS7中的详细错误

This article should help you: 本文将为您提供帮助:

In earlier versions of IIS, error messages from classic ASP scripts were sent to a Web browser, by default. 在早期版本的IIS中,默认情况下,来自经典ASP脚本的错误消息已发送到Web浏览器。 Because these error messages might reveal sensitive information to malicious users, IIS 7 and above disables this feature by default. 由于这些错误消息可能会向恶意用户泄露敏感信息,因此IIS 7及更高版本默认情况下会禁用此功能。 When your classic ASP scripts encounter an error in IIS, you receive the following error message by default: 当您的经典ASP脚本在IIS中遇到错误时,默认情况下会收到以下错误消息:

 An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error. 

I doubt this will work for everyone but in the end I was able to force the hand of IIS by deleting the setting for a 500 custom error pages in the "Error Pages" setting of the website in IIS. 我怀疑这对每个人都适用,但是最后我能够通过删除IIS网站的“错误页面”设置中的500个自定义错误页面的设置来强制IIS进行操作。 It appears that when it couldn't find the template for the custom error it spat out the real error. 似乎当找不到自定义错误的模板时,它吐出了真正的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM