今天在写代码时调试发现web form程序里的每次请求sessionid都不一样?这样就导致每次换页都要查数据库运行一些基础数据的查询,影响性能。
网上查到的解析是这样的:
When using cookie-based session state, ASP.NET does not allocate storage for session data until the Session object is used. As a result, a new session ID is generated for each page request until the session object is accessed. If your application requires a static session ID for the entire session, you can either implement the Session_Start method in the application's Global.asax file and store data in the Session object to fix the session ID, or you can use code in another part of your application to explicitly store data in the Session object.
谁给解释下cookie based session state 和 默认的session state 有什么区别?
它有什么优点吗? 如何让它每次的SessionID不变?