Request对象:提供对当前页请求的访问,其中包括请求标题、Cookie、客户端证书、查询字符串等。
Get方式传递数据:
Request.QueryString[“name”];
Post方式传递数据:
Request.Form[“name”];
不用显示设置方式,系统依次按几种方式来处理:
Request.Params[“name”];
Request[“name”];
读取Cookie:
if (Request.Cookies["UserSettings"] != null) { string userSettings; if (Request.Cookies["UserSettings"]["Font"] != null) { userSettings = Request.Cookies["UserSettings"]["Font"]; } }
写入Cookie:
HttpCookie myCookie = new HttpCookie("UserSettings"); myCookie["Font"] = "Arial"; myCookie["Color"] = "Blue"; myCookie.Expires = DateTime.Now.AddDays(1d); Response.Cookies.Add(myCookie);