protected void Login_btn_Click(object sender, EventArgs e) { if (userid_textlogin.Text == "" || passwor_textlogin.Text == "") { emptyfielderrordiv.Visible = true; } else { loginclass loginclass = new loginclass(); int i = loginclass.LoginFirm(userid_textlogin.Text, passwor_textlogin.Text); if (i == 1) { Readfromsqlloginfirm readfromsqlloginfirm = new Readfromsqlloginfirm(); readfromsqlloginfirm.Readfromsqlloginfirmdetails(userid_textlogin.Text, passwor_textlogin.Text); Session["location"] = readfromsqlloginfirm.location.ToString(); Session["state"] = readfromsqlloginfirm.state.ToString(); Session["firmname"] = readfromsqlloginfirm.firmname.ToString(); Session["firmid"] = readfromsqlloginfirm.firmid.ToString(); Response.Redirect("CompanyHome.aspx"); } else { failedlogin_div.Visible = true; } } }
public async Task <ActionResult> Index(loginclass Info) { var client = new HttpClient(); //var client = new HttpClient(); //var responseTask = await client.GetAsync("https://localhost:44309/api/values"); //if (responseTask.IsSuccessStatusCode) //{ // var sss= await responseTask.Content.ReadAsStringAsync(); if (ModelState.IsValid) { using (client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:63847"); //HTTP POST if (string.IsNullOrEmpty(Info.PassCode)) { var httpContent = new StringContent(JsonConvert.SerializeObject(Info), Encoding.UTF8, "application/json"); var postTask = client.PostAsync("api/Register", httpContent); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { loginclass Infor = JsonConvert.DeserializeObject <loginclass>(await result.Content.ReadAsStringAsync()); return(View(Infor)); } } } } else { using (client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:63847"); var httpContent = new StringContent(JsonConvert.SerializeObject(Info), Encoding.UTF8, "application/json"); var postTask = client.PostAsync("/api/Validate", httpContent); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { if (!Info.ShowPassCode) { Info.ShowPassCode = true; } if (!string.IsNullOrEmpty(Info.PassCode) && Info.ShowPassCode) { Info.LoggedIn = true; } //} return(View(Info)); } } } return(View(Info)); }