Cookie
Cookie的用法也和ASP中差不多。比如我们建立一个名为aspcn,值为飞刀的cookie
HttpCookie cookie = new HttpCookie["aspcn"];
cookie.Value = "飞刀";
Response.AppendCookie(cookie);
我们取出Cookie值也很简单
HttpCookie cookie = Request.Cookies["aspcn"];
cookieValue = cookie.Value;
有时候我们想在一个Cookie中储存多个信息,那也没有问题。比如我们在名为aspcn的cookie下加多个信息
HttpCookie cookie = new HttpCookie("aspcn");
cookie.Values.Add("webmaster","飞刀");
cookie.Values.Add("writer","beige");
cookie.Values.Add("LinkColor","blue");
Response.AppendCookie(cookie);
取出信息也一样简单
HttpCookie cookie = Request.Cookies["aspcn"];
value1 = cookies.Values["webmaster"];
value2 = cookies.Values["writer"];