gpt4 book ai didi

asp.net-mvc-3 - 为什么 Session 在 ASP.NET MVC 应用程序中是一场灾难?

转载 作者:行者123 更新时间:2023-12-03 07:51:09 26 4
gpt4 key购买 nike

为什么这么说我们不应该在 ASP.NET MVC 应用程序中使用 session 变量 ?我遇到了this answer这么说的。在这种情况下,我将如何维护请求中的值,例如登录用户信息和与他的帐户关联的一些相关数据?

这是Darin的回答。

Why are you using HttpContext.Current in an ASP.NET MVC application? Never use it. That's evil even in classic ASP.NET webforms applications but in ASP.NET MVC it's a disaster that takes all the fun out of this nice web framework.

最佳答案

像 ASP.NET MVC 这样的框架的基本原则之一是它们是无状态的,就像 Web 一样。 ASP.NET Web 窗体是在无状态环境上模仿有状态范式的尝试。 It is a lie , 换句话说。

在 ASP.NET MVC 应用程序中使用 Session 变量有点像在马的头上绑一个角,并称它为 unicorn 。

关于asp.net-mvc-3 - 为什么 Session 在 ASP.NET MVC 应用程序中是一场灾难?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10181629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com