我有一个空检查代码,它正在检查响应对象中是否已经存在 cookie:
if (HttpContext.Current.Response.Cookies["CookieName"] != null)
{
sessionCookie = HttpContext.Current.Response.Cookies["CookieName"];
cookieValue = sessionCookie.Value;
}
当我通过调试器检查时,密钥在检查之前不存在,但在检查之后确实存在。因此 cookie 的返回值为 null。检查 cookie 是否存在会自动创建 cookie?
提前致谢