views:

295

answers:

2

im currently setting up asp.net to accept DELETE http verb in the application. However, when i send

"DELETE /posts/delete/1"

i always get a 405 Method not allow error. I tried to take a look at the header:

Response Headers
Cache-Control   private
Pragma  No-Cache
Allow   GET, HEAD, OPTIONS, TRACE
Content-Type    text/html; charset=utf-8
Server  Microsoft-IIS/7.5, Private-Server
Date    Tue, 17 Nov 2009 18:30:31 GMT
Content-Length  5590

Allow GET, HEAD, OPTIONS, TRACE

notice the Allow header in IIS7, it's only allow GET HEAD OPTIONS and TRACE. I currently using [AcceptVerbs(HttpVerbs.Delete)] in my delete controller (i think this one is extended by MVCContrib, correct me if im wrong)

PS: i send DELETE using Javascript:

  function _ajax_request(url, data, callback, type, method) {
      if (jQuery.isFunction(data)) {
          callback = data;
          data = {};
      }
      return jQuery.ajax({
          type: method,
          url: url,
          data: data,
          success: callback,
          dataType: type
      });
  }

and:

 _ajax_request($(this).attr('href'), "", function(d) { alert("submit"); }, "json", 'DELETE');

THank you in advance!

A: 

Check this question.

Bruno Reis
already check. and i cannot find the solution for the 405 error
DucDigital
+1  A: 

MVC 2 has this built in. You don't need MVCContrib for it. See HtmlHelper.HttpMethodOverride and HttpDelete.

Craig Stuntz
should i go for asp.net mvc 2 since it's still in beta stage? :)
DucDigital
Up to you. We have (not production yet, but soon). Works fine.
Craig Stuntz