public ActionResult login(string username, string password) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri("http://localhost:55550/api/"); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var responseTask = httpClient.GetAsync("User/GetSession?name=" + username + "&password="******"Something...username="******"user"] = user; if (user.RoleName == "admin" || user.RoleName == "editor") { return(Redirect("/post")); } return(Redirect("../Home/")); } return(Redirect("../Account")); }
// // GET: /User/ public ActionResult Index() { if (Session["user"] == null) { return(Redirect("/Account")); } usersession user = Session["user"] as usersession; if (user.RoleName != "admin") { return(Redirect("/Account")); } return(View()); }