在调试时,写入后马上取值没有问题,在ie下也没问题
/// <summary>
/// 保存Cookies
/// </summary>
public void WriteCookies()
{
string cookievalue = this.Serializable();
System.Diagnostics.Debug.WriteLine(cookievalue); HttpCookie cookie = HttpContext.Current.Request.Cookies[_cookiesName];
if (cookie == null)
{
cookie = new HttpCookie(_cookiesName);
}
cookie.Value = cookievalue;
cookie.Expires = DateTime.Now.Add(_effcTimes);
HttpContext.Current.Response.AppendCookie(cookie);
} /// <summary>
/// 获取Cookies
/// </summary>
/// <param name="cookiename">Cookie名称[不允许为空] 空则异常</param>
/// <returns></returns>
public static CookiesHelper ReadCookies(string cookiename)
{
CookiesHelper result = null;
if (string.IsNullOrEmpty(cookiename) == true)
{
throw new Exception("this arge 'cookiename' is not allow null or empty!");
}
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[cookiename] != null && HttpContext.Current.Request.Cookies[cookiename] != null)
{
string cookievaluetemp = HttpContext.Current.Request.Cookies[cookiename].Value;
result = CookiesHelper.Deserialize(cookievaluetemp ); } return result;
}
GoogleCookie
/// <summary>
/// 保存Cookies
/// </summary>
public void WriteCookies()
{
string cookievalue = this.Serializable();
System.Diagnostics.Debug.WriteLine(cookievalue); HttpCookie cookie = HttpContext.Current.Request.Cookies[_cookiesName];
if (cookie == null)
{
cookie = new HttpCookie(_cookiesName);
}
cookie.Value = cookievalue;
cookie.Expires = DateTime.Now.Add(_effcTimes);
HttpContext.Current.Response.AppendCookie(cookie);
} /// <summary>
/// 获取Cookies
/// </summary>
/// <param name="cookiename">Cookie名称[不允许为空] 空则异常</param>
/// <returns></returns>
public static CookiesHelper ReadCookies(string cookiename)
{
CookiesHelper result = null;
if (string.IsNullOrEmpty(cookiename) == true)
{
throw new Exception("this arge 'cookiename' is not allow null or empty!");
}
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[cookiename] != null && HttpContext.Current.Request.Cookies[cookiename] != null)
{
string cookievaluetemp = HttpContext.Current.Request.Cookies[cookiename].Value;
result = CookiesHelper.Deserialize(cookievaluetemp ); } return result;
}
GoogleCookie
解决方案 »
- 在ASP.NET技术中,如何通过代码将PDF文件转换为Word或者Html文件
- Workflow 启动多线程
- 关于FileUpload的问题
- membership问题
- 导入数据到数据库时有客户查询怎么办??
- 登录失败问题
- 哪里有C#版的asp.net入门书籍下载呀?
- aspx页面无法运行,aspx文件编译后的警告:运行时错误,未将对象引用设置到对象实例
- 初学抽象工厂,碰到Type.GetType返回null问题
- 请问一下如果学习mongodb等NOSQL数据库还需要学习LINQ或者ADO吗????
- 单独运行Crystal能拉出数据,程序打印调用,浏览器一直停留不动?
- asp.net加载....
希望这边文章对你有所帮助