c# - MVC 获取与发布

标签 c# asp.net-mvc http-get

在了解 MVC 概念时,我了解到在“GET”操作中包含更改服务器对象状态(数据库更新等)的代码不是一个好习惯。 “缓存返回数据”已作为原因给出。

有人可以解释一下吗?

提前致谢!

最佳答案

这是 HTTP 标准。 GET 动词应该是幂等且安全的。

9.1.1 Safe Methods

Implementors should be aware that the software represents the user in their interactions over the Internet, and should be careful to allow the user to be aware of any actions they might take which may have an unexpected significance to themselves or others.

In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.

Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

关于c# - MVC 获取与发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19413166/

相关文章:

java - 在http get请求中设置对象

c# - 在 C# 中比较两个 PDF 文件

c# - 使用 Kinect 进行人脸检测

javascript - 使用 HTTP GET 和 Google App Script 访问 Google 电子表格的标题

javascript - 拖放到数据库 mvc 后保存图像顺序

c# - 用于小写下划线到 CamelCase 的自定义 Json.NET 契约(Contract)解析器

http-status-codes - HTTP GET 响应返回 202 "Accepted"是否错误?

c# - IsAssignableFrom 与 COM

c# - WebDriverBackedSelenium 可以在 C# 中使用吗

javascript - 客户端总是响应之前服务器发送的事件,而不是当前事件