c# - 进程外的 session 变量会导致内存问题吗?

标签 c# asp.net session-state session-variables

在我当前的asp.net 应用程序中,我将 session 变量 存储在SQL 服务器 中。如果您指定 InProc,则 session 保存在服务器内存中,但对于 out of proc(在我的例子中), session 保存在 SQL 服务器中。

这是真的吗?根据我的阅读,每个需要 session 访问的请求(基本上每个页面请求)都会从 db 反序列化 session ,并在请求完成后将其保存回来。这意味着一旦检索到这些值,它们将保留在 Web 服务器上。这与 InProc 有何不同?

对于 Out of Proc,是否仅在请求时检索一个 session 变量?否则,在我看来它与 InProc 相同。我错过了什么。

最佳答案

Is this really true?

是的,这是真的。

From what I read, with every request that needs session access (basically every page request) will deserialize the session from db and save it back once the request completes. This means that the values will be kept on the web server once it is retreived. How is this different from the InProc then?

值仅在 HTTP 请求期间存储在内存中。在请求开始时,它们从 SQL Server 加载,在请求结束时,它们被保存到 SQL Server 中。这与 InProc 不同,InProc 在请求之间将值保存在内存中。由于不同的请求(来自同一用户)可以由服务器场中的不同节点提供服务,因此使用 SQL Server 可以保证场中的所有节点都将共享相同的 session 值。

关于c# - 进程外的 session 变量会导致内存问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7680421/

相关文章:

javascript - 在 IE11 中取消 JavaScript 事件

c# - 使用 ASP.NET 中的函数设置 imageURL

c# - Xamarin MvvM 内容 View 绑定(bind)

c# - 使用 C# 和 asp.net 将 CSV 文件导入 SQL

c# - 让 SqlBulkCopy 接受列名

asp.net-mvc - ASP.NET MVC 中何时调用 Session_End()?

c# - 更改 ASP.NET session 状态 cookie 的到期时间

c# - 这个 "singleton"在 ASP.NET 应用程序中应该是线程安全的吗?

c# - 默认 Azure 移动应用程序后端返回 500

c# - 发布到 IIS 时,文件隐藏代码未更新