我有以下代码......
private readonly string CookieName = ConfigurationManager.AppSettings["CookieName"];
public void AddCookie(HttpContext context)
{
var uniqueId = Guid.NewGuid().ToString();
context.Response.Cookies.Add(new HttpCookie(CookieName, uniqueId));
}
因此cookie以 no 值到达浏览器。有什么想法吗?
干杯,伊恩。
答案 0 :(得分:1)
您是否可以测试或重构代码以使用类似的内容?
HttpCookie c = new HttpCookie("foo");
c.Expires = DateTime.Now.AddDays(99);
c.Values[CookieName] = Guid.NewGuid().ToString();
HttpContext.Current.Response.Cookies.Add(c);