codebased
codebased

Reputation: 7073

405 Method Not Allowed PUT

I have checked everything and none of the configuration is working fine.

THE GET, POST is working however with put I am getting 405 message. I don't have WebDEV.

This is my configuration.

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <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>
  </system.webServer>

It is driving me nuts!

I have referred all available suggestions such as : Asp.NET Web API - 405 - HTTP verb used to access this page is not allowed - how to set handler mappings

enter image description here

Even though I am using Basic Auth/ Windows Auth. disabling this also makes no difference.

[System.Web.HttpHttpPut] public override HttpResponseMessage Put(int id, Request entity) { .... }

NOTE: I have just put on staging server and it has worked. However, it is not working on my machine... enter image description here

enter image description here

Upvotes: 5

Views: 17988

Answers (2)

Ranjit Kolkar
Ranjit Kolkar

Reputation: 1

Your Browser is set to default method GET. You can use Postman Chrome extension to test all the HTTP Methods.

Upvotes: -1

Kristof
Kristof

Reputation: 3315

Did you decorate your action with HttpPut from the correct namespace? Should look something like this :

[HttpPut]
public ActionResult ActionName() 
{
  //Your code
}

Edit: Apparently iis express has delete & put disabled by default. If this only happens in iis express you might find this answer usefull. Basicly you have to edit this file :

%userprofile%\documents\iisexpress\config\applicationhost.config 

On this line:

<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

And add the verb PUT

Edit nr 2:
Following This anwser : open up your iis manager and select you website.
Click handler mapping link on the right.
Find the ExtensionlessUrlHandler-Integrated-4.0 entry and double click it.
In Request Restrictions tab verbs you can then add put to enable put support.

Upvotes: 7

Related Questions