public async Task <ActionResult> AddBikeFromCart(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($"Bicycles/{id}"); if (res.IsSuccessStatusCode) { var response = res.Content.ReadAsStringAsync().Result; Bicycle bicycle = JsonConvert.DeserializeObject <Bicycle>(response); cart.AddBicycle(bicycle); cart.LocationId = bicycle.LocationId; HttpContext.Session.SetString("Cart", JsonConvert.SerializeObject(cart)); GetShoppingCart(); return(Redirect(url)); } } TempData["Message"] = "Error has occured."; return(Redirect(url)); }