private void Page_Load(object sender, System.EventArgs e)
{
Response.Cookies[ "Count "].Value = "100 ";
for(int i=0;i <5;i++)
{
Response.Cookies[ "Count "].Value = Convert.ToString(Convert.ToInt32(Request.Cookies[ "Count "].Value)+1);
Response.Write(Request.Cookies[ "Count "].Value+ " <br> ");
}
}
第一次访问页面结果如下:
101
102
103
104
105
然后在不停的刷新页面,却成了下面形式?为什么不是第一次的结果呢??
105
105
105
105
105
---------
106
106
106
106
106
------------
107
107
107
107
107
------解决方案--------------------------------------------------------
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack){
Response.Cookies[ "Count "].Value = "100 ";
for(int i=0;i <5;i++)
{
Response.Cookies[ "Count "].Value = Convert.ToString(Convert.ToInt32(Request.Cookies[ "Count "].Value)+1);
Response.Write(Request.Cookies[ "Count "].Value+ " <br> ");
}
}
}