2014-12-05 109 views
0

我有一个asp按钮,并且在单击事件上设置了会话变量并且页面被重定向。问题是这个过程需要两次点击 - 一次设置会话,另一次重定向。如何设置会话并单击重定向?我的代码如下:设置会话变量时阻止页面重新加载

protected void btn_login_Click(object sender, EventArgs e) 
{ 
     HttpContext.Current.RewritePath("AnotherPage.aspx"); 
     Session.Add("user-id", _id); 
} 
+0

第一届添加,然后重定向 – Tushar 2014-12-05 21:31:43

回答

0
protected void btn_login_Click(object sender, EventArgs e) 
{  
    Session.Add("user-id", _id); 
    Response.Redirect("AnotherPage.aspx"); 
}