I am getting this error in my custom class. The code is as follows, I highlighted the line where I get there error, and I already checked that the cookie exists:
static private Dictionary<string,string> KeyValueGet()
{
Dictionary<string, string> ArrKeyVal = new Dictionary<string, string>();
NameValueCollection CookieData = new NameValueCollection();
**if (HttpContext.Current.Request.Cookies["CartData"].Values != null)**
{
CookieData = HttpContext.Current.Request.Cookies["CartData"].Values;
string[] CookieKeys = CookieData.AllKeys;
foreach (string s_key in CookieKeys)
{
ArrKeyVal.Add(s_key, CookieData[s_key]);
}
}
return ArrKeyVal;
}
UPDATE: I added an If statement that check's for 'null,' it doesn't even get through this, I get the same exception inside the if statement, it looks like it cannot process what HttpContext.Current.Request is.
Any input is appreciated.