Translate Into English Coffee & Tea
ASP.NET 中的 AJAX ASP.NET 画图全接触 ASP.NET 与 XML 声明式数据绑定 ASP.NET 网页抓取
C# 基础 C# 类教程 C# 加密 ASP.NET 成员资格 非“自动化”处理 Excel
QuickAjax Ajax 完美的语法高亮器 Silverlight Popfly
通栏广告
ASP.NET 中使用 Cookie
ASP.NET 中的 Cookie 和 ASP 中的 Cookie 是不共享的。

写 Cookie 示例

HttpCookie cookie = new HttpCookie("foo", "123"); //参数为 cookie 名称和值
DateTime dt = new DateTime(2008, 3, 3, 1, 1, 1); //参数为年、月、日、时、分、秒
cookie.Expires = dt; //设置过期时间
Response.SetCookie(cookie); //写 Cookie

不能像 ASP 一样,使用 response.Cookies("foo") = "3" 来设置,ASP.NET 中使用 SetCookie。

ASP.NET 中 Response.Cookies["foo"].Value 是有效的,它是个只读属性。

读 Cookie 示例

Request.Cookies["foo"].Value
文章评论
标题:必填
内容:
文章信息