Search code examples
c#asp.nethttp-request

HTTP DELETE Request returning a (405) Method Not Allowed Error. Why?


I'm attempting to send a DELETE request through csharp, ASP.NET and its returnin a (405) Error. Below is the code that I'm using:

request = System.Net.HttpWebRequest.Create(myTargetURL); request.Method = "DELETE"; response = (System.Net.HttpWebResponse)request.GetResponse();

Anybody can shed some light on this? is it something I'm not doing from a code point of view?


Solution

  • Looks like everything is working properly on your end and sounds like the server you are sending your DELETE method request to does not allow it.

    10.4.6 405 Method Not Allowed

    The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.