G
Guest
Hi all,
I have a property that stores a value to a cookie and retrieves it if the
cookie exists or returns a default value if it doesn't in my web app.
private static string ID
{
get
{
if(HttpContext.Current.Request.Cookies["ID"] != null)
{
return HttpContext.Current.Request.Cookies["ID"].Value;
}
else
{
return "-1";
}
}
set
{
HttpCookie connectionIDCookie = new HttpCookie("ID", value);
HttpContext.Current.Response.Cookies.Add(IDCookie);
}
}
This has worked fine apart from with browsers based on the windows 98 O/S.
If the cookie exists it enters the 'if/else' block but returns a null for
the cookie value. However if I break during debugging at this point and enter
'HttpContext.Current.Request.Cookies["ID"]' into the command window all the
details are returned and when continuing stepping through the code the value
is now returned.
I am a bit stumped at this point as to why this is happening. A solution
would be to store it in a session variable instead but I would like to know
if anyone has any idea why this is happening?
Thanks for looking, Andy
I have a property that stores a value to a cookie and retrieves it if the
cookie exists or returns a default value if it doesn't in my web app.
private static string ID
{
get
{
if(HttpContext.Current.Request.Cookies["ID"] != null)
{
return HttpContext.Current.Request.Cookies["ID"].Value;
}
else
{
return "-1";
}
}
set
{
HttpCookie connectionIDCookie = new HttpCookie("ID", value);
HttpContext.Current.Response.Cookies.Add(IDCookie);
}
}
This has worked fine apart from with browsers based on the windows 98 O/S.
If the cookie exists it enters the 'if/else' block but returns a null for
the cookie value. However if I break during debugging at this point and enter
'HttpContext.Current.Request.Cookies["ID"]' into the command window all the
details are returned and when continuing stepping through the code the value
is now returned.
I am a bit stumped at this point as to why this is happening. A solution
would be to store it in a session variable instead but I would like to know
if anyone has any idea why this is happening?
Thanks for looking, Andy