Forum Xamarin.Android

Login Validation

Xammy10Xammy10 Member ✭✭✭

I'm creating a login validation using API as my database, here is my code:

private void Lgnbtn_Click(object sender, System.EventArgs e)
HttpClient client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;
var Url = string.Format("");
var response = client.GetAsync(Url + "test/Test").Result;
var data = response.Where(x => x.user == userName.Text && userPass.Text).FirstOrDefault();
if (data != null)
Toast.MakeText(this, "Login Success", ToastLength.Short).Show();
Toast.MakeText(this, "Username or Password invalid", ToastLength.Short).Show();
catch (Exception ex)
Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();

But "Where" has a red under line, I know there's something wrong with my code. But I'm just trying if this thing will work.
Or do you have some source code or link to help me?\

Thanks in advance :)


  • GyllionGyllion NLMember ✭✭
    edited March 2018

    'Where' is a Linq function. Try adding this above your file:

    using System.Linq;
Sign In or Register to comment.