在A页面中,设置Cookies值:
HttpCookie httpCookie;
if (HttpContext.Current.Request.Cookies[name] != null)
HttpContext.Current.Request.Cookies.Remove(name);
httpCookie = new HttpCookie("cookieTest","Hello,world!");
httpCookie.Expires = DateTime.Now.AddHours(10);
HttpContext.Current.Response.AppendCookie(httpCookie);用IE打开B页面,在B页面中,读Cookies:
HttpCookie httpCookie;
string value = null;httpCookie = HttpContext.Current.Request.Cookies[name];
if (httpCookie != null)
value = httpCookie.Value;
问题现象:
httpCookie 为 null另外:
如果不用IE打开B页面,而从A页面打开B页面,却可以读到 Cookies。
A、B两个页面在同一工程。
HttpCookie httpCookie;
if (HttpContext.Current.Request.Cookies[name] != null)
HttpContext.Current.Request.Cookies.Remove(name);
httpCookie = new HttpCookie("cookieTest","Hello,world!");
httpCookie.Expires = DateTime.Now.AddHours(10);
HttpContext.Current.Response.AppendCookie(httpCookie);用IE打开B页面,在B页面中,读Cookies:
HttpCookie httpCookie;
string value = null;httpCookie = HttpContext.Current.Request.Cookies[name];
if (httpCookie != null)
value = httpCookie.Value;
问题现象:
httpCookie 为 null另外:
如果不用IE打开B页面,而从A页面打开B页面,却可以读到 Cookies。
A、B两个页面在同一工程。
解决方案 »
- 求SESSION解决方案
- ext treepanle 异步加载代码
- UTC时间格式转换Sat Feb 20 09:49:46 +0800 2010
- 迷茫行动迷茫行动??????速来。。
- 关于1+2,有点难度的问题
- 面试时的问题,给你一个网站,你如何下手???高手请进,顶者有分
- FreeTextBox输入文字设置大小后 在页面显示< FONT size=6>此处文字< /FONT> 怎么去掉HTML标识只显文字??
- Page中的Server.HtmlEncode()的问题
- 急求解决办法点击安钮不打开新窗口的方法
- ajax怎么不能和图片上传一起使用啊?
- ???ASP.NET(C#)中使用OWC导出excel时如何设置excel文件的格式
- 50分求个适合初学asp.net+VB.net的整站源码,感谢
// httpCookie.Expires = DateTime.Now.AddHours(10);
这句代码是注释掉了。
if (HttpContext.Current.Request.Cookies["name"] != null)
HttpContext.Current.Request.Cookies.Remove("name");
httpCookie = new HttpCookie("name","Hello,world!");
httpCookie.Expires = DateTime.Now.AddHours(10);
HttpContext.Current.Response.AppendCookie(httpCookie);
读cookieHttpCookie httpCookie;
string tt=null;httpCookie = HttpContext.Current.Request.Cookies["name"];
if (httpCookie != null)
tt = httpCookie.Value;
Response.Write(tt);
需要达到的是不要设置 Cookies 的过期期限。
就是说问题描述中的
httpCookie.Expires = DateTime.Now.AddHours(10);
这句代码被注释掉******
httpCookie.Expires = DateTime.Now.AddHours(10);
整个功能是问题的
现在讨论的是不要那句代码
httpCookie.Expires = DateTime.Now.AddHours(10);
整个功能是没有问题的
现在讨论的是不要那句代码