selvi jp

selvi jp

  • NA
  • 323
  • 69.7k

Login page in wep api mvc

Apr 23 2021 12:37 PM
I want to create login page using authentication token.ApplicationOAuthProvider alread have functionality for login.but i dont know how to call the function in controller
 This is i try
 [HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult Login(Login model)
        {
            HttpClient hc = new HttpClient();
            hc.BaseAddress = new Uri("https://localhost:44357/Token");

            var insertdata = hc.PostAsJsonAsync<Login>("Token", model);
            insertdata.Wait();

            var savedata = insertdata.Result;
            if (savedata.IsSuccessStatusCode)
            {
                ViewBag.message = "The user" + model.UserName + "Is Saved Successfully ... !";
                return View("Home");
            }

            return View();

        }

Answers (2)