Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Its not Umbraco related question but this community is so frendly that i will ask here.
I want to save cookie every time visitor comes to my website and before I do that I want to check if cookie alredy exist.
I am doing this with this static method:
public bool IsReturningVisitor(string value)
if (Request.Cookies[value] != null)
Response.Cookies[value].Value = value;
Response.Cookies[value].Expires = DateTime.Now.AddMinutes(1);
But I am geting null reference on this line Request.Cookies[value] != null .
When i do the same thing in my ActionResult class it works good.
Request.Cookies[value] != null
What am I missing??
Are you sure you have a Request? If you do it in a static class with a static method you might not have the Request object available.
If you have a Request object, check to see what the Cookies property actually contains, maybe what you think your key is, is not what it actually is.
Yes that is true, Request is null. I cant find solution how to solve it.
Is there a way to get the cookies in that situation?
Yes. You can get the Request/Response object from HttpContext.Current.Request/Response.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted