我知道 SessionState
属性可用于为对特定 MVC Controller 的请求设置 SessionStateBehavior
。我的问题是,如何以编程方式确定当前请求的 SessionStateBehavior
?我看到 HttpContext
有一个 internal property for this ,但有什么办法可以公开处理这个问题吗?
特别是,我想知道 session 状态行为是否被禁用。
最佳答案
HttpContext.Current.Session == null
将检查禁用的 session
HttpContext.Current.Session.IsReadOnly
将检查只读 session
关于c# - 如何获取请求的 SessionStateBehavior?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32766858/