因程序中Global.ascx被删除了,同一次登录, 跳转到其它页面, 此时后台Session的SessionID总是变化的. 导致取不到Session的值,经过调查发现, 只要在Global.ascx中加入:
<script>
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
就可保证同一次会话的SessionID不变.
前提是类要实现接口IRequiresSessionState,在VS2013中测试发现,IReadOnlySessionState不能起作用