作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在工作的项目有一大堆 JSON 操作,以便通过 ajax 调用填充级联下拉列表。由于它们在技术上是 Select 查询,而我们正在尝试使用 RESTful,因此我们一直使用 HttpGet
标记这些操作。属性。但是默认情况下,JsonResult
不允许通过 GET 返回结果。所以我们必须明确地调用 Json(data, JsonRequestBehavior.AllowGet)
.
我想知道的是,这是不好的做法吗?我们应该只允许对我们的 Json 操作发出 Post 请求吗?如果它有所作为,则这是一个企业应用程序,需要先登录到特定环境才能访问它。
最佳答案
在我的实践中,我使用下一条规则来决定哪种 HTTP 方法适合某种情况:如果您只检索数据,则使用 GET,如果您正在更改某些内容的状态,则使用 POST。
来自 www.w3.org :
Use GET if:
- The interaction is more like a question (i.e., it is a safe
operation such as a query, read operation, or lookup).Use POST if:
- The interaction is more like an order, or
- The interaction changes the state of the resource in a way that the user would perceive (e.g., a subscription to a service), or
- The user be held accountable for the results of the interaction.
关于asp.net-mvc - MVC2 JSON 操作,如果我想成为 RESTful,我应该允许 GET、POST 还是两者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4688351/
使用登录后,我想吐出用户名。 但是,当我尝试单击登录按钮时, 它给了我力量。 我看着logcat,但是什么也没显示。 这种编码是在说。 它将根据我在登录屏幕中输入的名称来烘烤用户名。 不会有任何密码。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
我是一名优秀的程序员,十分优秀!