【发布时间】:2010-12-13 05:03:23
【问题描述】:
我在设置 cookie 时看到了一些奇怪的东西...
行动:
string cookieName = "foo";
string cookieValue = "bar";
//Set a cookie in the response, along with the Expires.
this.ControllerContext.HttpContext.Response.Cookies.Add(
new HttpCookie(cookieName, cookieValue)
{
Expires = DateTime.Now.AddHours(1)
}
);
调试时,我可以看到这个新的 cookie 将在未来一小时到期,然而,当我在视图中查看 cookie 时,到期时间不存在......
查看:
<%= Request.Cookies.Get("foo").Value %>
返回bar。
<%= Request.Cookies.Get("foo").Expires %>
返回01/01/0001 00:00:00
有什么想法吗?!
【问题讨论】:
标签: c# asp.net-mvc cookies