protected void Button1_Click(object sender, EventArgs e) { /* * Get the service reference */ UserControlServiceReference.ServiceClient client = new UserControlServiceReference.ServiceClient(); /* * See if the given credentials belong to an authorized user */ string authorizedUser = client.AuthenticateUser(TextBox1.Text, TextBox2.Text); string[] output = authorizedUser.Split('-'); /* * Create a cookie for the user if the validation is successful */ if (output[0] == "Validation Successful") { HttpCookie httpCookie = new HttpCookie("userCookie"); httpCookie["username"] = TextBox1.Text; httpCookie["role"] = output[1]; httpCookie.Expires = DateTime.Now.AddMonths(6); Response.Cookies.Add(httpCookie); Response.Redirect("Home.aspx"); } else { /* * Else return the status accordingly */ Label2.Text = output[0]; } }
protected void Button1_Click(object sender, EventArgs e) { /* * Check for the matching text from the image service */ if (TextBox4.Text == "{NO0B}") { /* * Register user on successful image verification */ UserControlServiceReference.ServiceClient client = new UserControlServiceReference.ServiceClient(); Label3.Text = client.RegisterUser(TextBox1.Text, TextBox2.Text, TextBox3.Text); } else { /* * Return appropriate message in case of failure */ Label3.Text = "Please enter a matching string for the image provided"; } }