ASP.net MVC cookie problem
I've got the following code...
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));
}
So the cooki开发者_如何学编程e arrives at the browser with no value. Any ideas?
Cheers, Ian.
Are you able to test or refactor the code to use something like this?
HttpCookie c = new HttpCookie("foo");
c.Expires = DateTime.Now.AddDays(99);
c.Values[CookieName] = Guid.NewGuid().ToString();
HttpContext.Current.Response.Cookies.Add(c);
精彩评论