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!

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.