我在webconfig里面定义了session的失效时间 <sessionState mode="InProc" timeout="1" cookieless="true">
</sessionState>我想在Global.asax文件里面判断:代码如下 void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
// 如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。
Application.Lock();
if (Session["userid"] == null || Session["realname"] == null)
{
Response.Write("页面已失效,请重新登录!");
Response.End();
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('页面已失效,请重新登录!');location='../Default.aspx'", true);
}
Application.UnLock(); }哪位能帮我解决一下!谢了,急急急
</sessionState>我想在Global.asax文件里面判断:代码如下 void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
// 如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。
Application.Lock();
if (Session["userid"] == null || Session["realname"] == null)
{
Response.Write("页面已失效,请重新登录!");
Response.End();
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('页面已失效,请重新登录!');location='../Default.aspx'", true);
}
Application.UnLock(); }哪位能帮我解决一下!谢了,急急急
void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
// 如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。
Application.Lock();
if (Session["userid"] == null || Session["realname"] == null)
{
Response.Write("页面已失效,请重新登录!");
Response.End();
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('页面已失效,请重新登录!');location='../Default.aspx'", true);
}
Application.UnLock(); }
没有效果
Session_End()中是无法获得HttpContext对象的
Session_End是被动触发
怎么写呢
适用stateserver保存session