Subramanyam Reddy

Subramanyam Reddy

  • 1.3k
  • 403
  • 343

Xamarin Project login Page Not working

Jun 19 2021 8:09 AM

I created the Xamarin project and in that I created login page and code is below shown

private async void Button_Clicked(object sender, EventArgs e)
        {

            bool Exist=false;
            try
            {

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("http://localhost:59737/");
                string UserName = CivilID.Text;
                string pswd = Password.Text;
                string url = "api/Aldaman/CheckLoginUser?UserName=" + UserName + "&Password=" + pswd + "";
                HttpResponseMessage response = client.GetAsync(url).Result;

                if (response.IsSuccessStatusCode)
                {
                    string content = await response.Content.ReadAsStringAsync();
                    if (!string.IsNullOrEmpty(content))
                        Exist = Convert.ToBoolean(content);
                    else
                        Exist = false;
                }
                if (Exist)
                {
                   await Navigation.PushModalAsync(new NavigationPage(new MasterFlyout()));
                }

            }
            catch(Exception ex)
            {
                string err = ex.Message;
            }
        }

 

===>  for login I created another web API project but when I try to run the above code URL not triggering to API project but when i tried in Postman response getting but in code not working.so what will be the issue


Answers (2)