Reputation: 667
I run into 500 - Internal Server Error when PUT/DELETE
with windows 2008 server IIS. The response I get is:
<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>
When I check my custom logs of my WebAPI I find that the call has not even hit the service.
My earlier experience was getting 404 - Not Found for PUT
and DELETE
and this behavior was consistent across Win7 and Win 2008 Server. For that I found this fix:
I applied the fix and PUT/DELETE
works on windows 7. But after that when deployed the same service on IIS 7 in win2008 server I do not get 400. But I get "500 - Internal Server Error" from IIS or something even before that.
The same code works perfectly on windows 7 (IIS 7.5).
Any clues on resolution of such issues?
Edited Aug 29, 2012:
The issue of 500-Internal Server Error is detected by enabling fault-tracing in IIS7. The fix is this configuration.
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
Basically we need to remove "WebDAVModule" from modules and also remove "WebDAV" from Handlers. But now I am back to my old issue of 404-Not Found. Now even after having the below configuration i cannot get PUT/DELETE to work:
<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" />
Unusually the same web application works perfectly on hosted separately (not under default web site) on the same system same IIS. So I suspect this is due to some parent website configuration which filters PUT/DELETE requests.
Any ideas on the same?
Upvotes: 6
Views: 8813
Reputation: 5414
I had the same issue recently on my Win Server 2008 R2 / IIS 7.5 and it took me couple of hours just to found out it was caused by LiveStreamingHandler. LiveStreamingHandler module on the IIS causes the PUT
and DELETE
HTTP verb error.
Uninstall the Media Services 4.1 with Add and Remove program and reboot the server fixes this issue. Hope this help someone.
Upvotes: 1
Reputation: 211
I make the Neil S` information more exact:
So, 404 and 405 error for Put method was disappeared, I receive 200 status.
This solution works for me.
Upvotes: 4
Reputation:
Try turning on custom error by adding
<customErrors mode="Off" />
You will see the actual cause of the 500 error when you browse to the API controller, e.g.: http://staging.site.com/api/book.
You will find more clues from the actual exception messages.
Upvotes: 0
Reputation: 2304
After agonizing over a very similar problem, I came upon this solution: http://www.iis.net/configreference/system.webserver/security/requestfiltering/verbs
Using the Request Filtering settings, I was able to globally allow the PUT and DELETE verbs in IIS, which solved my problem. It ended my nightmare of 404.6 errors. (btw, I did not have webDAV installed and did add the verbs to the ExtensionlessUrlHandler)
Hopefully this info can save someone some time.
Upvotes: 4