统一身份验证
定义一个基类:
public class BasePage:System.Web.UI.Page
{
public BasePage()
{
//
// TODO: 在此处添加构造函数逻辑
//
this.Load += new EventHandler(BasePage_Load);
}
void BasePage_Load(object sender, EventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
//如果用户没有登录,就跳转到登录页面
if (Session["UserName"] == null)
{
Response.Redirect("~/admin/login.aspx");
}
}
}
然后在所有需要身份验证的页面继承BasePage类即可

浙公网安备 33010602011771号