在http中实际使用GET,PUT,DELETE,POST方法 [英] Actual use of GET,PUT,DELETE,POST methods in http

查看:909
本文介绍了在http中实际使用GET,PUT,DELETE,POST方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net web API(RESTful服务),我可以通过提供一些额外的参数来使用post方法进行删除,插入和更新操作。是否仅用于可以区分功能的单词的语义用法?。

I am using asp.net web API(RESTful service) where I can use post method for delete, insert and update operation by giving some extra parameters. Is it used for only semantic usage of the words that can differentiate functionality?.

我发现很好的SO帖子这里。有一些疑问如下

I found nice SO post Here. There are some doubts as below


  1. 我可以使用POST发布数据然后 PUT

  2. 我可以通过传递已删除的ID删除POST,然后为什么删除

  3. 会发生什么在服务器端,它为每个接收到这样的标题方法。

请协助相同的。谢谢..

Please assist for the same. Thanks..

推荐答案

REST架构的架构属性之一是简洁的界面。 GET,POST,PUT等是早期可用的众所周知的HTTP动词。 REST仅定义了如何使用它们来实现RESTFUL实现。如果你按照它们进行RESTful实现,如果没有......你正在做一些只有你知道的事情。

One of the Architecture properties of REST Architecture is "Simplicity of Interface". GET, POST, PUT etc. are well known verbs of HTTP that were available earlier as well. REST only defines how these can be used to achieve RESTFUL implementation. If you follow them you are doing RESTful implementation, if not .. you are doing something that only you know.

您也可以使用GET来删除记录(通过在查询字符串中提供ID并编写底层实现来删除QS中提供的任何ID)但是如何一个梦想世界之外的人会知道如果我用GET做到这一点,记录将被删除。

You can make use of GET as well to delete a record (by just providing ID in query string and writing underlying implementation to delete whatever ID is supplied in QS) but how will a person outside of your dream world know that if I do that with GET, the record will be deleted.

所有动词都被REST架构分配用途,以便大家都知道会发生什么。如果你不遵循它们,你就会创建一些非标准的东西。

All the verbs are assigned a purpose by REST Architecture so that everybody knows what is going to happen. If you don't follow them, you are creating something that is not standard.

如果按照REST的定义(来自 wiki ):

If you go by definition of REST (from wiki):


具象状态转移(REST) )是一个软件架构
样式,由一组协调的架构约束组成,应用于
分布式超媒体系统中的组件,连接器和数据元素。 REST忽略组件
实现和协议语法的细节,以便专注于
组件的角色
,与其他
组件交互时的约束,以及它们重要数据元素的解释。

Representational state transfer (REST) is a software architectural style consisting of a coordinated set of architectural constraints applied to components, connectors, and data elements, within a distributed hypermedia system. REST ignores the details of component implementation and protocol syntax in order to focus on the roles of components, the constraints upon their interaction with other components, and their interpretation of significant data elements.

这篇关于在http中实际使用GET,PUT,DELETE,POST方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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