Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 ASP.NET 4.0 中有一个新方法 HttpContext.SetSessionStateBehavior,我们可以通过它在运行时更改会话状态。但是在应用程序开发中我们需要使用这种方法的真实例子是什么?
在 4.0 之前,只有两种方法可以禁用会话状态。
如果您的应用程序根据查询字符串动态生成页面,那么您没有办法选择性地禁用某些页面的会话状态以提高性能。因此,您只需禁用所有页面或启用所有页面。
有了这个,您可以编写一个可以拦截请求的 http 模块,查看查询字符串或 url 的路径并禁用/启用会话状态。