i am lost, now the most simple things wont work for me.
Okay, so if i run this script with only Step1 – It will returns “NotNull” – good!
If i then run it With only Step 2 it would as expected return “Null” – good!
But if i then remove Both Step 1 AND 2 (After removing the cookie with step2)
It switches back to “NotNull” – Baad!
How can that be? How can i check if a cookie is Null !?
Hope you can help 🙂
//Step 1
HttpContext.Response.Cookies.Add(new HttpCookie("test") { Name = "test", Expires = DateTime.Now.AddDays(2) });
//Stem 2
HttpContext.Request.Cookies["test"].Expires = DateTime.Now.AddDays(-2);
HttpContext.Request.Cookies.Remove("test");
HttpContext.Request.Cookies.Clear();
string test = "Null";
if (HttpContext.Request.Cookies["test"] != null)
{
test = "NotNull";
}
return Content(test);
In the second step you are trying to modify cookies but you still working with
Requestobject. To submit your modifications you needResponseobject. So, after your 2nd step cookies still alive.