读书人

Cookies 更新不及时,该怎么解决

发布时间: 2012-02-01 16:58:19 作者: rapoo

Cookies 更新不及时
//获得搜索参数开始
string SearchTypes = DDL_SearchTypes.Text;
string Key = tb_Key.Text.ToString();
if (SearchTypes != " " && Key != " ")
{
intPageNo = 1;
Response.Cookies[ "strc "].Value = "And " + SearchTypes + " Like ' " + '% ' + Key + '% ' + " ' ";
//Session[ "strc "] = "And " + SearchTypes + " Like ' " + '% ' + Key + '% ' + " ' ";

}
//string str_Condition = Session[ "strc "].ToString();
string str_Condition = Request.Cookies[ "strc "].Value.ToString();
//Response.Write(str_c);
Response.Write(str_Condition);
//获得搜索参数结束


每次换关键字搜索要点两次,str_Condition的值才会变,Cookies更新不及时,第一次清寒是显示的老的,第二次才显示新的.

[解决办法]
是的,这样解决
string x = "And " + SearchTypes + " Like ' " + '% ' + Key + '% ' + " ' ";
Response.Cookies[ "strc "].Value = x;
string str_Condition = x;

[解决办法]
用Session吧

读书人网 >asp.net

热点推荐