写入Cookie
protected void Button4_Click(object sender, EventArgs e){
//写入Cookie
HttpCookie nc = new HttpCookie("newCookie");
nc.Value["name"] = "HMS";
nc.Value["age"] = "25";
nc.Value["dt"] = DateTime.Now.ToString();
Response.Cookies.Add(nc);
Response.Write("Cookie写入成功!");
}
不知道这段代码错在哪了,下面是错误提示:
错误 1 与“string.this[int]”最匹配的重载方法具有一些无效参数 D:\WebAppliation\WebAppliationtest\Default.aspx.cs 42 9 D:\WebAppliation\WebAppliationtest\
错误 2 参数“1”: 无法从“string”转换为“int” D:\WebAppliation\WebAppliationtest\Default.aspx.cs 42 18 D:\WebAppliation\WebAppliationtest\
总共6处,不过是重复的,nc三处都错另外三处是"name"、"age"、"dt"