在一般处理程序中 为什么要调用两次DelCookies方法才能删除掉啊 感觉是cookies的问题 public void DelCookies(HttpContext context)
{
if (context.Request.Cookies["restoreid"] != null)
{
HttpCookie tempCurBuyerList = context.Request.Cookies["restoreid"];
string[] strArr = tempCurBuyerList.Value.Split(',');
System.Collections.ArrayList al = new System.Collections.ArrayList(strArr);
al.Remove(context.Request["Vid"]); HttpCookie cookie = new HttpCookie("restoreid"); //设置cookies到期时间
cookie.Expires = DateTime.Now.AddDays(-2);
context.Response.Cookies.Add(cookie);
// context.Request.Cookies.Remove("restoreid");
for (int i = 0; i < al.Count; i++)
{//循环添加没有被删除的cookies
HistoryRestore("restoreid", Int32.Parse(al[i].ToString()));
}
context.Response.Write(getHist());
}
else {
context.Response.Write("暂无浏览记录");
}
} public string getHist()
{
HttpRequest Request = HttpContext.Current.Request;
string temp = "";
if (GetLastProducts().Count != 0)
{
for (int i = 0; i < GetLastProducts().Count; i += 12)
{
temp += "<li><span><a href='?VideoId=" + GetLastProducts()[i] + "&Re=1'>" + GetLastProducts()[i + 1] + "</a></span><a href='?VideoId=" + GetLastProducts()[i] + "&Re=1'>继续观看</a><input title='删除' type='button' value='X' onclick='Delcookies(" + GetLastProducts()[i] + ")' ></li>";
}
}
else
{
temp = "暂无浏览记录";
}
return temp;
} public List<string> GetLastProducts()
{
HttpRequest Request = HttpContext.Current.Request;
System.Collections.ArrayList lists = new System.Collections.ArrayList();
List<string> list = null;
if (Request.Cookies["restoreid"] != null)
{
HttpCookie tempCurBuyerList = Request.Cookies["restoreid"];
string[] strArr = tempCurBuyerList.Value.Split(',');
list = new List<string>();
for (int j = 0; j < strArr.Length; j++)
{
list.AddRange(new Video().search_voide(strArr[j], 1, 1, 1));
}
}
return list;
}
{
if (context.Request.Cookies["restoreid"] != null)
{
HttpCookie tempCurBuyerList = context.Request.Cookies["restoreid"];
string[] strArr = tempCurBuyerList.Value.Split(',');
System.Collections.ArrayList al = new System.Collections.ArrayList(strArr);
al.Remove(context.Request["Vid"]); HttpCookie cookie = new HttpCookie("restoreid"); //设置cookies到期时间
cookie.Expires = DateTime.Now.AddDays(-2);
context.Response.Cookies.Add(cookie);
// context.Request.Cookies.Remove("restoreid");
for (int i = 0; i < al.Count; i++)
{//循环添加没有被删除的cookies
HistoryRestore("restoreid", Int32.Parse(al[i].ToString()));
}
context.Response.Write(getHist());
}
else {
context.Response.Write("暂无浏览记录");
}
} public string getHist()
{
HttpRequest Request = HttpContext.Current.Request;
string temp = "";
if (GetLastProducts().Count != 0)
{
for (int i = 0; i < GetLastProducts().Count; i += 12)
{
temp += "<li><span><a href='?VideoId=" + GetLastProducts()[i] + "&Re=1'>" + GetLastProducts()[i + 1] + "</a></span><a href='?VideoId=" + GetLastProducts()[i] + "&Re=1'>继续观看</a><input title='删除' type='button' value='X' onclick='Delcookies(" + GetLastProducts()[i] + ")' ></li>";
}
}
else
{
temp = "暂无浏览记录";
}
return temp;
} public List<string> GetLastProducts()
{
HttpRequest Request = HttpContext.Current.Request;
System.Collections.ArrayList lists = new System.Collections.ArrayList();
List<string> list = null;
if (Request.Cookies["restoreid"] != null)
{
HttpCookie tempCurBuyerList = Request.Cookies["restoreid"];
string[] strArr = tempCurBuyerList.Value.Split(',');
list = new List<string>();
for (int j = 0; j < strArr.Length; j++)
{
list.AddRange(new Video().search_voide(strArr[j], 1, 1, 1));
}
}
return list;
}
cookie.Expires = DateTime.Now.AddDays(-2);
context.Response.Cookies.Add(cookie);
context.Request.Cookies.Remove("xxx");