我的问题是,当我按下我的按钮(这会导致回发)时,click_event
中产生的cookie没有在我调用Page_Load
的方法中处理。当Page_Load()被触发时cookie没有被处理
下面是代码:
//Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if(!Context.User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
}
loadCookies();
}
//loadCookies
public void loadCookies()
{
for (int i = 0; i < 40; i++)
{
if(Request.Cookies["FiscaleTable" + i.ToString()] != null){
TableRow row = new TableRow();
for (int i2 = 0; i2 < 10; i2++)
{
TableCell cell = new TableCell();
cell.Text = Request.Cookies["FiscaleTable" + i.ToString()][i2.ToString()];
row.Cells.Add(cell);
}
FiscaleEenhedenTable.Rows.Add(row);
}
}
}
//Button_Click
public void makeFiscaleEenhedenCookie(object sender, EventArgs e)
{
ContentPlaceHolder Content;
Content = (ContentPlaceHolder)Master.FindControl("MainContent");
HttpCookie FiscaleEenhedenCookie = new HttpCookie("FiscaleTable" + (FiscaleEenhedenTable.Rows.Count - 1).ToString());
FiscaleEenhedenCookie.Expires = DateTime.Now.AddDays(1d);
for (int i2 = 0; i2 < 10; i2++)
{
TextBox temp = (TextBox)Content.FindControl("FiscaleUnitTextBox" + (i2 + 1).ToString());
FiscaleEenhedenCookie[i2.ToString()] = temp.Text;
}
Response.Cookies.Add(FiscaleEenhedenCookie);
}
//Button
<asp:Button ID="FiscaleAddButton" runat="server" CommandName="FiAdd" Text="Toevoegen" ClientIDMode="Static" OnClick="makeFiscaleEenhedenCookie"/>
只要我调用另一个回发或刷新的cookie被处理的页面。我不知道为什么会发生这种情况。任何帮助将是有益的。
@TusharGupta你的意思是在if语句中吗?因为这与这个问题无关。重定向工作正常。 – 2015-02-24 09:54:14
M抱歉我的不好...我的理解不同 – Tushar 2015-02-24 09:57:24