为什么MVC无状态 - 如何解释? [英] Why is MVC stateless - How to explain?

查看:155
本文介绍了为什么MVC无状态 - 如何解释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

While explaining concepts of ASP.NET MVC to my students

MVC是无状态的。它是建立在另一个无国籍的顶
  协议 - HTTP和HTTPS

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

但一个学生打断,问,

您告诉大家,MVC是无状态的。

You tell that the MVC is stateless

无状态协议从来没有关心,如果响应回来还是不从
  服务器。但是,在ASP.NET MVC框架,你犯了一个请求,并等待
  响应。既然你等待响应,它应该被称为
  作为一个有状态的服务。你怎么都称这是一个无状态服务
  然后呢?

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?

我真的卡住了起来,不知道怎么回答这个问题。

I really got stuck up and wondered what to answer to this question.

任何想法?

推荐答案

MVC是不是无状态的,HTTP是。

MVC is not stateless, HTTP is.

HTTP无状态并不意味着它是发射后不管。客户端不会等待响应。它是在这个意义上的无状态的两个连续请求都毫无关系。

HTTP being stateless doesn't mean it is fire and forget. The client does wait for the response. It is stateless in the sense that two successive requests have no relation whatsoever.

国家可以使用会话来模拟,例如使用的cookies。

State can be emulated using sessions, for example using cookies.

这篇关于为什么MVC无状态 - 如何解释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆