2

I'm trying to make my webservice(.asmx) to be able to respond to PUT and DELETE methods, but it always returns a 404 error.

I managed to get it to respond to GET method, by adding the following to my web.config:

  <system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>
  </system.web>

Now, what is it that I have to do in order to get it to respond to PUT and DELETE methods?

I've already tried adding things like the code below(and lots of other stuff i've found here), without success:

  <system.webServer>
    <handlers>
      <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>
    <modules>
      <remove name="WebDAVModule" />
    </modules>
  </system.webServer>

Does anybody know what should I do?

John Saunders
  • 157,405
  • 24
  • 229
  • 388
alvesdm
  • 43
  • 8
  • 1
    ASMX is a legacy technology, and should not be used for new development. WCF or ASP.NET Web API should be used for all new development of web service clients and servers. One hint: Microsoft has retired the [ASMX Forum](http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads) on MSDN. – John Saunders May 08 '14 at 04:13
  • I don't believe there's any way to get ASMX to handle PUT or DELETE. You should switch to WCF or ASP.NET Web API in any case. – John Saunders May 08 '14 at 04:14
  • 1
    I am sure about `asmx` but both `WCF Rest service` & `ASP.NET Web API` provide this out-of-box without much toil. – Pranav Singh May 08 '14 at 04:26
  • 1
    Too bad! I'm using a .asmx for the sake of simplicity. I wouldn't like add an entire WEB Api project, since I just need to handle one single request from the front end, that can come using both verbs. – alvesdm May 08 '14 at 17:24

0 Answers0