什么时候应该在ASP.NET MVC应用程序中使用HttpDelete或HttpPut [英] When should I use HttpDelete or HttpPut in an asp.net mvc application

查看:228
本文介绍了什么时候应该在ASP.NET MVC应用程序中使用HttpDelete或HttpPut的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我的操作正在数据库上执行删除方法,我也总是使用HttpGet或HttpPost.

I use always HttpGet or HttpPost even when my action is executing a delete method on the database.

然后我应该使用HttpDelete/HttpPut吗?

For what should I use then HttpDelete/HttpPut ?

推荐答案

如果您构建 OData 服务.

HTTP DELETE -删除指定资源代表的实体数据.有效负载不存在于请求或响应消息中.

HTTP DELETE - Deletes the entity data that the specified resource represents. A payload is not present in the request or response messages.

HTTP PUT -用请求消息的有效负载中提供的新数据替换请求资源上的现有实体数据. ( msdn )

HTTP PUT - Replaces existing entity data at the requested resource with new data that is supplied in the payload of the request message. (msdn)

与Scott Hanselman的演示. (我还没有看到.)

There's a presentation with Scott Hanselman that might be interesting. (I haven't seen it yet.)

如果您有关于OData的关于复数视觉的一些讲座,订阅在那里.

There's also a couple of lectures on pluralsight on OData if you have a subscription there.

这篇关于什么时候应该在ASP.NET MVC应用程序中使用HttpDelete或HttpPut的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆