tags:

views:

62

answers:

3

It seems impossible to define PUT when I use Html.BeginForm to submit a form whilst updating an item. Is this correct?

Thanks.

Christian

+1  A: 

Yes, this is correct. Browsers only support GET and POST for sending forms. You could use AJAX though:

$.ajax({
    url: '/action',
    type: 'PUT',
    data: { param1: 'value1' },
    success: function(result) {

    }
});

And if you want to AJAXify a form submission you may take a look at the jquery.form plugin.

Darin Dimitrov
that's what I used to do in the past (using jquery). did not know that you cannot put a form - should a decent browser not be able to do this if it would be 'restful'/use html correctly or do i talk nonsense?
csetzkorn
+1  A: 

... should a decent browser not be able to do this if it would be 'restful'/use html correctly or do i talk nonsense?

According to the HTML4 spec, Form element only supports GET and POST. Technically any browser that allows other verbs would be out of spec. It looks like HTML5 will support other verbs though.

Edit: and it looks like now I can link to both documents.

R0MANARMY
Thanks I will accept Darin's answer.
csetzkorn
A: 

If you use ASP.NET MVC 2, check Html.HttpMethodOverride method and HttpPutAttribute.

ASP.NET MVC 1.0 also check MVC 2 source code. HttpRequestExtensions.GetHttpMethodOverride method is very cool!

takepara