When I attempt to access a cookie, I get the following exception:
Object reference not set to an instance of an object.
This is the line in question:
if (Request.Cookies["selectBoxValue"].Value != null)
Controller
[Authorize]
public ActionResult Index()
{
if (Request.Cookies["selectBoxValue"].Value != null)
{
HttpCookie groupId = new HttpCookie("selectBoxValue");
groupId = Request.Cookies["selectBoxValue"];
// Collect all comments connected to current group
int t = Convert.ToInt32(groupId.Value);
pv.ListofComments = db.Comments.Where(dp => dp.GroupID == t).ToList();
// Show only groups connected to current user
var CurrentUser = User.Identity.GetUserId();
var groupUser = db.GroupUsers.Where(u => u.ApplicationUserId == CurrentUser).Select(gr => gr.GroupId).ToList();
pv.GroupList = db.Groups.Where(g => groupUser.Contains(g.Id));
return View(pv);
}