public async Task <ActionResult> RedirectOauth() { if (Session["userName"] == null) { return(RedirectToAction("Login")); } string url = Request.QueryString["url"]; UserOnlieModel model = Session["userName"] as UserOnlieModel; HttpClient httpclient = new HttpClient(); httpclient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", model.AlarmToken); var respone = await httpclient.GetAsync(url); return(Content(await respone.Content.ReadAsStringAsync())); }
public ActionResult Vail() { var res = Request.Form["userName"] == Request.Form["password"]; if (Request.Form["userName"]?.Length > 1 && res) { var obj = new UserOnlieModel() { UserId = Guid.NewGuid().ToString(), UserName = Request.Form["userName"], AlarmToken = GetAccessToken() }; Session["userName"] = obj; return(RedirectToAction("Index")); } return(RedirectToAction("Login")); }