asp.net-mvc – 为什么应该使用HTTP POST或DELETE而不是GET删除?

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 为什么应该使用HTTP POST或DELETE而不是GET删除?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在通过微软的ASP.NET MVC教程,最后在这个页面

http://www.asp.net/learn/mvc/tutorial-32-cs.aspx

下面的语句是在这个页面底部

In general,you don’t want to perform an HTTP GET operation when invoking an action that modifies the state of your web application. When performing a delete,you want to perform an HTTP POST,or better yet,an HTTP DELETE operation.

这是真的?任何人都可以提供更详细的解释这个声明背后的理由吗?

编辑

Wikipedia规定如下:

Some methods (for example,HEAD,GET,OPTIONS and TRACE) are defined as safe,which means they are intended only for information retrieval and should not change the state of the server.

By contrast,methods such as POST,PUT and DELETE are intended for actions which may cause side effects either on the server

解决方法

Jon Skeet的答案是规范的答案。但是:假设你有一个链接
href = "\myApp\DeleteImportantData.aspx?UserID=27"

和google-bot来和你的页面索引?那么会发生什么呢?

猜你在找的asp.Net相关文章