• 主页
  • ASP
  • .NET Framework
  • Web Services
  • VB
  • VC
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • LINQ

菜鸟cookie大问题,在线等,救命呀

huangbihui 2004-12-28 10:05:09
上一页:
HttpCookie cookie = new HttpCookie("aspcn");
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0,0,6,0);
cookie.Expires = dt.Add(ts);
while(dr.Read())
{
cookie.Values.Add("webmaster","admin");
cookie.Values.Add("programer1","pwd");
cookie.Values.Add("programer2","grade");
cookie.Values.Add("programer3","username");
cookie.Values.Add("programer2","ipaddresslast");
cookie.Values.Add("programer3","department");
}

Response.AppendCookie(cookie);
Response.Redirect ("dep_admin_lk.aspx");

下一页:
HttpCookie readcookie = Request.Cookies["aspcn"];

Cookie1.Text = readcookie.Values["admin"].ToString();

出现出错信息:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 7: HttpCookie readcookie = Request.Cookies["aspcn"];
Line 8:
Line 9: Cookie1.Text = readcookie.Values["admin"].ToString();
...全文
23 点赞 收藏 回复
写回复
回复

还没有回复,快来抢沙发~

发动态
发帖子
.NET技术社区
创建于2007-09-28

4.9w+

社区成员

66.8w+

社区内容

.NET技术交流专区
社区公告
暂无公告