这个是页面验证类。
public class DNAPageBase : Page
{
HttpSessionState ses = HttpContext.Current.Session;
public DNAPageBase()
{
if(ses["DNA_USER"]==null)
{
......
}
}
}
这个是调用main.aspx页面继承
public partial class main : DNAPageBase
{
}
执行过程中,总是报错,ses["DNA_USER"]==null为空这个错误?
------解决方案--------------------------------------------------------
public class BasePage : System.Web.UI.Page
{
public Model.Users userInfo = new Model.Users();
/// <summary>
/// 构造函数
/// </summary>
public BasePage()
{
this.Load += new EventHandler(BasePage_Load);
}
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void BasePage_Load(object sender, EventArgs e)
{
CheckUserLogin();
}
/// <summary>
/// 登录验证
/// </summary>
public void CheckUserLogin()
{
if (Session["DNA_USER"] == )
{
}
}
}