javascript - ajax 可以使 Web 应用程序有状态吗?

标签 javascript ajax asp.net-mvc stateless stateful

Ajax 可以在浏览器上返回信息,而无需刷新。这是否意味着它将 ID 存储在 session /有状态行为中?我没有看到基于 Ajax 的 Web 应用程序中的 URL 发生任何变化。我正在查看的示例是 - http://evolvingweb.github.io/ajax-solr/examples/reuters/index.html 。我正在尝试比较在 ASP.NET MVC 中开发的无状态 UI 与在 javascript 框架中使用 ajax 开发的 UI

最佳答案

HTTP 是一种无状态协议(protocol)。来自 Http RFC :

The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. It is a generic, stateless, protocol which can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its request methods, error codes and headers. A feature of HTTP is the typing and negotiation of data representation, allowing systems to be built independently of the data being transferred.

Ajax 并不像您想象的那样: 来自 W3C :

AJAX = Asynchronous JavaScript and XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.

ASP.NET State Management可以使用 Cookie、 session 、Browser Cache 来完成(HTML5 提供浏览器数据库用于缓存)、Profile、SQL Server 缓存、QueryStrings、HiddenFields。

构建响应用户的 Web 应用程序是一种新趋势,SPA (单页应用程序)使用在 JavaScript 中构建的 Ajax 和 MVVM 框架提供出色的用户体验。

幕后黑手SPA ,使用 Microsoft ASP.NET MVC,是 Jonh Papa .

关于javascript - ajax 可以使 Web 应用程序有状态吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17837174/

相关文章:

javascript - 如何使用 jQuery 循环遍历表并查找元素?

javascript - jQuery 没有正常运行,立即打印警报

c# - 动态表单创建 - XSD XML SQL

javascript - 固定页眉滚动时的标题转换

javascript - Firebase JavaScript : Callback function does not return anything

javascript - CasperJS - 如何跳到下一个测试套件?

php - 如何将下拉列表中的值插入到 mysql 查询中以从数据库中检索数据

jquery - 如何定期触发 AJAX 请求?

javascript - 在 jquery/javascript 处理后移动到命名 anchor

c# - 从 JQuery 将 JSON 发布到 ASP.NET MVC 4 操作