从今天起开始学习ASP.Net web开发相关知识,说实在的不搞web方面的测试开发很多年了,呵呵! 1. Cookie 相关操作 protected void btnTest_Click(object sender, EventArgs e) { HttpCookie Wcookie = new HttpCookie("CheersLi"); Wcookie.Values["Name"] = "Cheers Li"; Wcookie.Values["Age"] = "27"; Wcookie.Values["Date"] = DateTime.Now.ToString(); Wcookie.Expires = DateTime.Now.AddDays(1d); Response.Cookies.Add(Wcookie); Response.Write("Write cookie successfully!~"); } protected void btnRCTest_Click(object sender, EventArgs e) { HttpCookie Rcookie = Request.Cookies["CheersLi"]; Response.Write(Rcookie.Values["Name"]); Response.Write("<br>"+Rcookie.Values["Age"]); Response.Write("<br>"+Rcookie.Values["Date"]); } protected void btnDeleteCookie_Click(object sender, EventArgs e) { if (Request.Cookies["CheersLi"] != null) { HttpCookie delCookie = new HttpCookie("CheersLi"); delCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(delCookie); Response.Write("Cookie has been deleted."); } }