在a.cs类中有一方法
public static bool LoginUser(...)
{...System.Web.HttpCookie cookie = new System.Web.HttpCookie("Info");
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(365,0,0,0,0);
cookie.Expires = dt.Add(ts);
cookie.Values.Add("abc",dr["ab"].ToString());
cookie.Values.Add("def",dr["cd"].ToString());
hc.Response.AppendCookie(cookie);...}
在方法LoginUser()中写入Cookies,下面在b.aspx中去读取
...
if(!this.IsPostBack)
{
...
System.Web.HttpCookie readcookie = new System.Web.HttpCookie("Info");
if(readcookie.Values["abc"] != null && readcookie.Values["def"] != null)
{
string aaa = readcookie.Values["abc"].ToString();
string bbb = readcookie.Values["def"].ToString();
}
....
}问:为什么在a.cs类中能读取到Cookies的值,在b.aspx中却读不到?
public static bool LoginUser(...)
{...System.Web.HttpCookie cookie = new System.Web.HttpCookie("Info");
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(365,0,0,0,0);
cookie.Expires = dt.Add(ts);
cookie.Values.Add("abc",dr["ab"].ToString());
cookie.Values.Add("def",dr["cd"].ToString());
hc.Response.AppendCookie(cookie);...}
在方法LoginUser()中写入Cookies,下面在b.aspx中去读取
...
if(!this.IsPostBack)
{
...
System.Web.HttpCookie readcookie = new System.Web.HttpCookie("Info");
if(readcookie.Values["abc"] != null && readcookie.Values["def"] != null)
{
string aaa = readcookie.Values["abc"].ToString();
string bbb = readcookie.Values["def"].ToString();
}
....
}问:为什么在a.cs类中能读取到Cookies的值,在b.aspx中却读不到?
解决方案 »
- iis7发布了MVC项目之后不能运行,.net 3.5的mvc项目一切正常,换成4.0的就不正常了
- 请问如何在html 中 用正则表达式 提取需要的内容
- 请教一个asp页面传值的问题
- mvc验证修改错误样式能满足我这样的需求吗
- 关于html编辑器eWebEditor的问题
- RequiredFieldValidator的问题?
- 一个UltraWebGrid保存问题?
- 请高手帮解答一下DataReapeater服务器控件的问题
- CSDN的一个BUG
- web控件运行时无法显示
- VS2005,在项目里添加了ASPNETDB.MDF数据库用来存储用户登陆信息,在安装程序时,可不可以在ASPNETDB.MDF中预制一个管理员帐号?
- session和cookies的区别
if(!this.IsPostBack)
{
...
System.Web.HttpCookie readcookie = Request.Cookies["Info"];//@@@@@@@@@@@@@@
if(readcookie.Values["abc"] != null && readcookie.Values["def"] != null)
{
string aaa = readcookie.Values["abc"].ToString();
string bbb = readcookie.Values["def"].ToString();
}
....
}
新建的cookie,当然是空的了
http://community.csdn.net/Expert/topic/4866/4866306.xml?temp=.3976404