有一个登陆页面login.aspx,一个主页面main.aspx
为了防止用户直接键入main.aspx,加入了一个judge.aspx进行页面判断!login.aspx:
在登录按钮单击事件里:
Session["enter"] = "Student";
Server.Transfer("main.aspx");
judge.aspx:
protected void Page_Load(object sender, EventArgs e)
{
//如果是用户直接键入,返回登陆页面
if ((String)Session["enter"] != "Student")
{
Server.Transfer("login.aspx");
}
}main.aspx:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Server.Execute("judge.aspx",false);先执行judge.aspx进行判断
}
} //超链接按钮单击事件
protected void LinkButton1_Click(object sender, EventArgs e)
{
Server.Transfer("login.aspx");
}
问题:
正常登陆后跳转到main.aspx后,超连接按钮不起作用了,原因是一开始执行了Server.Execute("judge.aspx",false);
怎么解决?
为了防止用户直接键入main.aspx,加入了一个judge.aspx进行页面判断!login.aspx:
在登录按钮单击事件里:
Session["enter"] = "Student";
Server.Transfer("main.aspx");
judge.aspx:
protected void Page_Load(object sender, EventArgs e)
{
//如果是用户直接键入,返回登陆页面
if ((String)Session["enter"] != "Student")
{
Server.Transfer("login.aspx");
}
}main.aspx:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Server.Execute("judge.aspx",false);先执行judge.aspx进行判断
}
} //超链接按钮单击事件
protected void LinkButton1_Click(object sender, EventArgs e)
{
Server.Transfer("login.aspx");
}
问题:
正常登陆后跳转到main.aspx后,超连接按钮不起作用了,原因是一开始执行了Server.Execute("judge.aspx",false);
怎么解决?
都用Transfer不可以?