gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:10:49 24 4
gpt4 key购买 nike

我最近发现,当您将页面设置为 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/

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