public IActionResult Login(User userModel) { HttpClient client = obj.AuthenticationInfo(); var contentType = new MediaTypeWithQualityHeaderValue ("application/json"); client.DefaultRequestHeaders.Accept.Add(contentType); /*UserDetail userModel = new UserDetail(); * userModel.Id = 1; * userModel.UserName = "******"; * userModel.Password = "******";*/ string stringData = JsonConvert.SerializeObject(userModel); var contentData = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync ("/api/Authentication", contentData).Result; string stringJWT = response.Content. ReadAsStringAsync().Result; JWT jwt = JsonConvert.DeserializeObject <JWT>(stringJWT); if (jwt.Token == null) { StatusMessage = "Invalid Username and Password"; TempData.Keep(); return(RedirectToAction("login")); } HttpContext.Session.SetString("token", jwt.Token); /*ViewBag.Message = "User logged in successfully!"; * * return View("Index");*/ //return Content("User Logged in Successfully"); TempData.Keep(); return(RedirectToAction("GetCartItems")); }