Friday 29 January 2016

ASP.NET MVC WebApi returned a 404 on a Windows 2003 R2 32-bit server

We promoted an ASP.NET MVC WebAPI project from Dev to Production.
It was working fine in dev and we XCOPYd the files from Dev to Production.
All of the IIS settings were comparable - or so we thought - so what can go wrong?

Well, the famous 404 error can. We were getting a 404 on all requests to the Web API.

We tried various things, like setting the
<modules runAllManagedModulesForAllRequests="true" />
element.

We did an aspnet_regiis.exe -i.

I checked we didn't have to allow 32-bit applications on a 64-bit machine.

We tried setting up a wildcard script map.

None of these worked. Nothing was showing in Event Viewer.

In the end we went to the IIS logs. We noticed the 404 code, but also a subcode 2 and sc-substatus of 1260. This article showed that it was a lockdown policy that prevented the request and the 1260 code indicated ERROR_ACCESS_DISABLED_BY_POLICY.
This was because under the Web Service Extensions branch in IIS Manager, the ASP.NET v4.0.30319 was set to prohibited.

Lesson learned - check the IIS log and look at the detailed error codes. The 404 has a subcode and the statuscode yields even more information.

No comments:

Post a Comment