0
我有设置过的用户认证数据一个cookie:对象引用错误
HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)));
现在,当我尝试读取使用另一个类的饼干:
HttpCookie myCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
myCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
我收到一个Object reference not set to an instance of an object
错误。
我检查了我的浏览器cookie和.ASPXAUTH
cookie与数据。
任何人都可以告诉我哪里出错了吗?我试着两个request
和response
编辑:HttpContext.Current.Request.Cookies.Get
返回相同的错误
EDIT2:好像HttpContext.Current
是null