asp.net中的cookie更新,刷新后才能取值

    protected void pagesize_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Request.Cookies["PageSize"] == null)
        {

    protected void pagesize_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Request.Cookies["PageSize"] == null)
        {
            HttpCookie NewCookie = new HttpCookie("PageSize", pagesize.Text.ToString());
            NewCookie.Expires = DateTime.Now.AddMinutes(5);
            Response.Cookies.Add(NewCookie);
            bind();
        }
        else
        {
            Response.Cookies["PageSize"].Value = pagesize.Text.ToString();
            Response.Cookies["PageSize"].Expires = DateTime.Now.AddMinutes(5);

        }
        Response.Redirect(Request.RawUrl);
     }

发表评论

电子邮件地址不会被公开。 必填项已用*标注