开发者

Html.BeginForm PUT

It seems impossible to define PUT when I use Html.BeginForm to 开发者_Go百科submit a form whilst updating an item. Is this correct?


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.


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!


... 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜