I've been through just about every article I can find, on SO and more. I've made changes to the Web.config
to meet the answers as they all seem to point to removing the WebDAV
module and handler.
However, I'm still getting the error:
405 Method Not Allowed
The requested resource does not support http method 'PUT'.
NOTE: this was originally just an MVC 4 project. I've added artifacts to support Web API. Seems like it's possible I may have missed something.
NOTE: the GET
calls are working just fine from Angular.
configuration.Routes.MapHttpRoute(
name: "Default API",
routeTemplate: "api/{controller}/{id}",
defaults: new { action = "Get", id = RouteParameter.Optional },
constraints: new { id = @"[\da-z-]{36}" });
configuration.Routes.MapHttpRoute(
name: "Default API with Action",
routeTemplate: "api/{controller}/{action}",
defaults: new { action = "Get" });
var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
formatter.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers accessPolicy="Read, Execute, Script">
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
PUT
API Entrypublic async Task<IHttpActionResult> Put([FromBody] EditUserViewModel viewModel)
vm.model.$update(function () {
$state.go(userStates.app);
});
Is it possible it's falling into the second route configuration? If so, how can I verify what route configuration .NET is trying to use?
In the end it appears to be the fact that I was trying to complicate the routing table. I ended up rolling it back to this:
configuration.MapHttpAttributeRoutes();
configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
Do take note to the fact that I added configuration.MapHttpAttributeRoutes();
as well.
After those two changes all is working well believe it or not. The Web.config
looks like this:
<handlers>
<remove name="ExtensionlessUrl-Integrated-4.0"/>
<add name="ExtensionlessUrl-Integrated-4.0"
path="*."
verb="*"
type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"
responseBufferLimit="0" />
</handlers>
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