public ActionResult deletepost(int id) { HttpCookie FromRequest = Request.Cookies["MyPosts"]; List <int> ids = new List <int>(); if (FromRequest != null) { string userids = FromRequest.Value; ids = userids.Split(',').Select(Int32.Parse).ToList(); } ids.RemoveAll(x => x == id); mng.DeletePost(id); string updatedids = ""; foreach (int b in ids) { updatedids += $",{b}"; } HttpCookie cookie = new HttpCookie("MyPosts", updatedids); Response.Cookies.Add(cookie); return(Redirect("~/Home/index")); }