The reason for this is because the type NameObjectCollectionBase , which Request.Cookies is derived from enumerations by collection keys, and not on top of the value. Therefore, when you list the Request.Cookies collection, you get the keys:
public virtual IEnumerator GetEnumerator() { return new NameObjectKeysEnumerator(this); }
This means that the following will work:
string[] keys = Request.Cookies.Cast<string>().ToArray();
I think you could try the following, which might be considered ugly, but will work:
List<HttpCookie> lstCookies = Request.Cookies.Keys.Cast<string>() .Select(x => Request.Cookies[x]).ToList();
UPDATE:
As pointed out by @Jon Benedicto in the comments section and in his answer using the AllKeys property AllKeys more optimal since it saves the cast:
List<HttpCookie> lstCookies = Request.Cookies.AllKeys .Select(x => Request.Cookies[x]).ToList();
Darin Dimitrov
source share