public async Task <ActionResult> AddAccessoryFromCart(int id, string url) { GetShoppingCart(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage res = await client.GetAsync($"Accessories/{id}"); if (res.IsSuccessStatusCode) { var response = res.Content.ReadAsStringAsync().Result; Accessories accessories = JsonConvert.DeserializeObject <Accessories>(response); cart.AddAccessories(accessories); HttpContext.Session.SetString("Cart", JsonConvert.SerializeObject(cart)); return(Redirect(url)); } } TempData["Message"] = "Error has occured."; return(Redirect(url)); }