I have an MVC App which is giving a 404 errors when i use POST requests.
Here's the pertinent bits of code:
I have a WebAPI controller(although this also happens with "pure" MVC controllers) with a single method in it:
public class GetSomeDataController : ApiController
{
[HttpPost]
public string GetNumbers([FromBody]string value)
{
// Get 10 randomised numbers
return //The numbers as JSON;
}
}
In the JavaScript i have an ajax request:
$.ajax({
type: "POST",
url: "/Api/GetSomeData/GetNumbers/",
data: JSON.stringify(requestData),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: false, // Pass the data in the body of the request rather than in the URI.
})
.done(function (ajaxResult) {
// handle the results
})
.fail(function (e) {
// Handle errors
});
When i debug it from within VS 2013 i get my 10 numbers back no problem at all. However when i run the exact same code in IIS 8.5...
The page itself is an MVC routed page so routing is working on the server, but it does not Work when I call a controller action from a POST.
The error page reports that the StaticFile handler appears to be trying to handle the request - which of course fails.
I am going out of my head trying to figure out what is going on. Does anyone have any ideas?
These are the things i can remember trying:
Adding various things to web.config (No Discernible effect):
<system.web>
<httpModules>
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
,
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
and
<system.webServer>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
</system.webServer>
- I am definitely running in Integrated mode
- The application pool is running under an account with access to the folder
- The application pool is running in .NET 4.0
- Disabling and re-enabling ASP.NET 4.5 in Windows features and settings
- aspnet_regiis - i (not supported for IIS 8.5)
Changing the ExtensionlessUrlHandler-Integrated-4.0 request path to "*"
- Changing the ExtensionlessUrlHandler-Integrated-4.0 verbs (POST is already included in the list)