Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 589
codebased Avatar asked Jul 24 '14 05:07

codebased


People also ask

What does 405 Forbidden mean?

A 405 Method Not Allowed Error is an HTTP response status code that indicates a web browser has requested access to one of your web pages and your web server received and recognized its HTTP method.

How do you fix 405 Method not allowed in Postman?

If you are certain you need a POST request, chances are, you're just using the wrong endpoint on the server. Again, this can only be solved if you have proper documentation to show what methods are supported for each endpoint.


Video Answer


1 Answers

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.

like image 150
Kristof Avatar answered Nov 13 '22 06:11

Kristof