我似乎无法使用以下代码在Google chrome上更新Cookie
[HttpPost]
public JsonResult _RemoveFromCart(int id)
{
var usr = CommonFunctions.GetLoggedUser();
HttpCookie mycookie = Request.Cookies[Sitesettings.UsersCart + "" + usr.Id];
List<Addtocart> lst = new List<Addtocart>();
if (mycookie != null && !string.IsNullOrEmpty(mycookie.Value))
{
string jsn = AESEncryptDecrypt.DecryptAsString(mycookie.Value);
lst = JsonConvert.DeserializeObject<List<Addtocart>>(jsn);
var item = lst.SingleOrDefault(x => x.id == id);
if (item != null && item.id > 0)
{
lst.Remove(item);
}
string jsnEnc = lst != null && lst.Count > 0 ? JsonConvert.SerializeObject(lst) : "";
mycookie.Value = lst != null && lst.Count > 0 ? AESEncryptDecrypt.EncryptAsString(jsnEnc) : "";
mycookie.Expires = DateTime.Now.AddDays(Sitesettings.CookieExpires);
Response.Cookies.Add(mycookie);
List<ProductModel> myret = lst != null && lst.Count > 0 ? CommonFunctions.GetProductsInCart() : new List<ProductModel>();
var retvalue = lst != null && lst.Count > 0 ? GetCartJson(myret, lst) : Json(new { success = false, itemcount = 0 });
return retvalue as JsonResult;
}
return Json(new { success = false, itemcount = 0 });
}
cookie中的值始终是相同的,并且似乎没有更新,而在调试中,我可以清楚地看到新值。
在Firefox上,它运行良好