c# - 为什么 MVC 是无状态的——如何解释?

标签 c# asp.net asp.net-mvc asp.net-mvc-4

在向我的学生解释 ASP.NET MVC 的概念时

MVC is stateless. It is built on top of another stateless protocol - HTTP and HTTPS

但一位学生打断并问道,

You tell that the MVC is stateless

Stateless protocol never cares if the response comes back or not from the server. But, in ASP.NET MVC framework, you make a request and wait for the response. Since you wait for the response, it should be called as a stateful service. How come you are calling it a stateless service then?

我真的很困惑,想知道如何回答这个问题。

有什么想法吗?

最佳答案

MVC 不是无状态的,HTTP 是。

HTTP 是无状态的并不意味着它是一劳永逸的。客户端确实等待响应。它是无状态的,因为两个连续的请求没有任何关系。

可以使用 session 模拟状态,例如使用 cookie。

关于c# - 为什么 MVC 是无状态的——如何解释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23470065/

相关文章:

asp.net - Azure 上的 Web 应用程序和数据库主机

c# - RedirectToAction 没有按预期刷新页面

c# - 如何在 asp.net mvc3 中显示矩阵表?

c# - 使用适当的数据类型是好的做法吗?

c# - 当应用程序的主视图关闭但辅助 View 仍然打开并从开始菜单打开应用程序时,如何恢复 UWP 应用程序的主视图?

c# - 发送更大尺寸的附件 asp.net

c# - 我应该如何在 ASP.NET MVC 4 服务提供商中实现 SAMLP 2.0?

c# - 使用 HTML AgilityPack 按断线解析 HTML

c# - WPF C# 提取并显示默认文件图标

javascript - 单击同一窗口上的链接打开新页面