asp.net - Inproc 模式下页面只读的 session 锁争用

标签 asp.net

我最近发现,当您将页面设置为 session readonly 并且您正在使用 inproc(内存中) session 存储时,该 session 仍然可以在该页面上写入并且不是真正的只读。进程外 session 存储确实尊重只读设置。

当页面设置为只读并使用 inproc 模式时,您是否仍然受益于没有 session 锁争用?在 readonly 和 inproc 中,具有相同 session ID 的多个并发请求是否必须等待 session 锁释放?

最佳答案

请参阅此博文:Handling multiple simultaneous requests from a user in ASP.NET :

  • enableSessionState="true" is the default behavior, and acquires a writer lock on session data. No other readers or writers can gain access while this lock is held.

  • enableSessionState="ReadOnly" acquires a reader lock on session data. Multiple readers are allowed simultaneously, but no writer can gain access if any reader holds a lock. Unfortunately, any changes you make to session are local to the request and not visible to other requests that look at the session object. No error is thrown if you try to modify a "read only" session, so this behavior is not obvious at first blush.

  • enableSessionState="false" doesn't acquire any lock. The HttpContext.Session property ends up being null, and your page will have no access to session data.

关于asp.net - Inproc 模式下页面只读的 session 锁争用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1313765/

相关文章:

asp.net - 如何显示数据库中的所有图像?

c# - 在 ASP.NET 5 中注册应用程序事件的处理程序

c# - 防止 ASP.NET Web 应用程序上的 SQL 注入(inject)

asp.net - HtmlHelper 在 Error.aspx 母版页中为空

asp.net - 从基于表单的身份验证中删除安全问题

asp.net - asp.net Web API 与发出 JSON 的 asp.net MVC Controller 的性能?

c# - 将 textbox.text 值与 SQL Server 中的值进行比较

c# - 无法将泛型类型加载到 ASP.NET 应用程序中的另一个 AppDomain

c# - 如何在 C# 中将此 05 :41:33 Apr 23, 2012 PDT 值转换为日期时间?

javascript - 鼠标中键单击链接仅打开新选项卡 ASP C#