会话变量保存在哪里?
会话变量到底保存在哪里?曲奇饼?服务器内存?
同样,应用程序变量保存在哪里?
Where exactly are session variables saved? Cookies? Server memory?
Again where are Application variables saved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
放入 Session 中的变量将存储在配置的 SessionStateProvider 配置为存储的位置。
默认的
SessionStateProvider
使用所谓的进程内 (InProc
) 会话,其存储位置位于服务器内存中,位于 ASP.NET 工作进程的内存空间内。您可以配置自己的 SessionStateProvider 来将 Session 变量存储在其他地方,例如进程外的数据库中。
应用程序变量存储在
ApplicationState
中,它也存储在 ASP.NET 工作进程的内存空间中。与会话状态不同,应用程序状态适用于所有用户和会话。据我所知,没有配置可以在其他地方存储 ApplicationState ;如果您需要存储大量应用程序数据,那么您可能需要查看 ASP.NET 缓存 。Variables put into Session are stored wherever the configured
SessionStateProvider
is configured to store them.The default
SessionStateProvider
uses what's referred to as In Process (InProc
) Session and the storage location for this is in server memory, inside the memory space of the ASP.NET worker process.You can configure your own
SessionStateProvider
to store Session variables elsewhere, such as out of process, in a database.Application variables are stored in
ApplicationState
which is also stored in the memory space of the ASP.NET worker process. Unlike Session State, Application State applies to all users and sessions. As far as I am aware, There is no configuration to store ApplicationState elsewhere; if you need to store lots of application data then you may want to look at ASP.NET Caching.会话变量与应用程序变量一样存储在服务器内存和磁盘上。
来自 ASP.NET 文档:
Session variables are stored on Server Memory and Disk as Application Variables are.
From ASP.NET documentation:
对于 InProc 会话,变量本地存储在 ASP.NET 工作进程的内存中。应用程序状态也是如此。
For an InProc session, variables are stored locally in memory of ASP.NET worker process. Same goes for application state.