5

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

Community
  • 1
  • 1
codebased
  • 6,945
  • 9
  • 50
  • 84

2 Answers2

7

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.

Community
  • 1
  • 1
Kristof
  • 3,267
  • 1
  • 20
  • 30
  • thank you for replying back. Yes it is linked to System.Web.Http. – codebased Jul 24 '14 at 06:07
  • Could you show your controller code as well? Maybe you have a parameter mismatch or you're targeting the wrong controller/action. – Kristof Jul 24 '14 at 07:09
  • @kristoff just did now. – codebased Jul 24 '14 at 09:24
  • Well if you've tried EVERYTHING then no, not really :) But in case you left some of the infinite actions open : Could you tell me if you are using IIS express or normal IIS? You could try to imitate the staging server with the same setup(IIS7 for example) and see if that does work to make sure the problem is really related to iis express or not. – Kristof Jul 25 '14 at 06:15
  • what version are you using? – Kristof Jul 25 '14 at 08:02
  • Its windows 8.1 IIS 8 – codebased Jul 25 '14 at 08:23
  • Take a look at edit nr 2 in my answer and let me know how if that fixed the issue. – Kristof Jul 25 '14 at 09:12
  • mate trust me it is also checked :( – codebased Jul 25 '14 at 09:20
  • Please see the modified question now, it has images attached.I have showed you what I did - even I have also set into "Request Filtering" option too. I have just created a new project with newly build ... everything new ... and it has same error. – codebased Jul 25 '14 at 09:25
  • For testing purposes, could you use a normal website in stead of a child application under ceds? Just to make sure no parent configuration is influencing your api.(The simpeler your case the closer the solution is ;) ) – Kristof Jul 25 '14 at 09:29
  • haha - let me try after sometime once again with some fresh air in. – codebased Jul 25 '14 at 09:30
  • ok problem solved. I was calling PUT with no ID !!!!! GRRRR... this link has given me the reference... http://social.msdn.microsoft.com/Forums/en-US/8a383373-326b-47e1-afd6-21bb05a59db8/webapi-v2-visual-studio-2013-iis-express-http-405-delete-method-not-allowed?forum=wcf – codebased Jul 27 '14 at 12:42
  • Omg. I spent ~20 hours on this, and I also did not use an id for put. I want to put this for an answer, but it's such a silly thing. I wish the error message was better than "Method not allowed" The PUT method was fine. – Michael Fulton May 01 '16 at 04:41
  • Anyone else having this and coming here where all the above didn't work: double-check whether you have `WebDAV` removed, both from the handlers and the module; if not it will also still disallow PUT and DELETE. – Vincent Sels Mar 06 '20 at 13:30
-1

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