I found the solution eventually! If you come across the same issue, add the following to your web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/> <!-- ADD THIS -->
</modules>
... rest of settings here
I hope this helps
In some cases removing it just from modules can produce next error:
500.21 Handler "WebDAV" has a bad module "WebDAVModule" in its module list
Module: IIS Web Core Notification: ExecuteRequestHandler"
solution was suggested here. Also need to remove it from handlers.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
In my case none of the above solutions was working. This was because I had changed the name of the parameter in my Delete
method.
I had
public void Delete(string Questionid)
instead of
public void Delete(string id)
I need to use the id
name because that's the name that is declared in my WebApiConfig
file. Note the id
name in the third and fourth lines:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
I got this solution from here.
The Javascript for HTTP DELETE
verb must be like this:
$.ajax({
**url: "/api/SomeController/" + id,**
type: "DELETE",
dataType: "json",
success: function(data, statusText) {
alert(data);
},
error: function(request, textStatus, error) {
alert(error);
debugger;
}
});
Do not use something like this:
...
data: {id:id}
...
as when you use the POST
method.
After trying almost every solutions here this worked for me. Add this in your APIs config file
<system.webServer>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<remove name="WebDAVModule" />
</modules>
</system.webServer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With