추가하지 않습니다 : - : 내가 요청에서 쿠키를 읽을 수 있어요 때쿠키
private void AddCookie(int id)
{
HttpCookie cookie = new HttpCookie("wmpayment");
cookie.Value = id.ToString();
cookie.Expires = DateTime.Now.AddDays(2);
this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);
}
을하지만 cookie.Expire는 날짜 01.01.0001
public static int WMPendingOrder
{
get
{
var cookie = HttpContext.Current.Request.Cookies["wmpayment"];
int id = 0;
DateTime exp;
if (cookie != null)
{
DateTime.TryParse(cookie.Expires.ToString(), out exp);
if (DateTime.Now < exp)
int.TryParse(cookie.Value, out id);
}
return id;
}
}
로그를 동일 쿠키. 이름 : 쿠키 쿠키. 값 : 0 쿠키. 확장 : 01.01.0001 0:00:00 나는이 문제를 이해하지 못한다.
의 조립
using System.Web.Security
를 추가 I 읽기 - 만료 = 01.01.0001 : ".. 그것을 바꿔주세요 .. 당신이 원하는 것을 이해하기가 어렵습니다 .. – Yasser나는이 튜토리얼이 대안으로 생각할 수 있음을 발견했다 : http://code-inside.de/blog -in/2010/10/19/howto-create-and-remove-cookies-asp-net-mvc/ – cpoDesign
나는 s 다음과 같이이 문제를 해결했습니다. 단순히 쿠키의 값을 다시 설정하기 위해 orderId를 '0'으로 설정하십시오. 그러나 브라우저가 쿠키를 서버에서 제거한 후에 제거하지 않는 이유는 매우 흥미 롭습니다. – user571874