首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-02-01 
Cookies 更新不及时//获得搜索参数开始stringSearchTypesDDL_SearchTypes.TextstringKeytb_Key.Text.To

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吧

热点排行