时间:2021-07-01 10:21:17 帮助过:13人阅读
using System;
using System.Web;
using System.Web.UI;
using System.Web.SessionState;
public class mana_session : Page
{
public mana_session()
{
}
protected override void OnInit(EventArgs e)
{
if (Session["uid"]== null || Session["uid"].ToString()=="")
{
Response.Redirect("login.htm");
}
}
}
代码如下:
using System;
using System.Web;
using System.Web.UI;
using System.Web.SessionState;
public class mana_session : Page
{
public mana_session()
{
}
protected override void OnInit(EventArgs e)
{
if (Session["uid"]== null || Session["uid"].ToString()=="")
{
Response.Redirect("login.htm");
}
}
}
在需要判断session的页面的cs文件中,将此文件继承于mana_session这个基类
例如
Csharp 代码
public partial class Index : mana_session