Hi everyone.
I'm trying to read a cookie inside an .aspx page but i don't seem to be getting there.
Here is my code:
try
{
HttpCookie cookie;
cookie = Request.Cookies.Get("name");
Label2.Text = cookie.Name;
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
I've also tried:
cookie = Request.Cookies["name"];
and no luck.
Label1 gets the message:
"Object reference not set to an instance of an object."
I know the cookie exists.
Ideas anyone?
Thanks in advance.
I'm trying to read a cookie inside an .aspx page but i don't seem to be getting there.
Here is my code:
try
{
HttpCookie cookie;
cookie = Request.Cookies.Get("name");
Label2.Text = cookie.Name;
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
I've also tried:
cookie = Request.Cookies["name"];
and no luck.
Label1 gets the message:
"Object reference not set to an instance of an object."
I know the cookie exists.
Ideas anyone?
Thanks in advance.