protected void btnSayHello_Click(object sender, EventArgs e) { using (var proxy = new SecuritySvc.HelloClient()) { try { // proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.PeerTrust; proxy.ClientCredentials.UserName.UserName = txtUserName.Text; proxy.ClientCredentials.UserName.Password = txtPassword.Text; lblMsg.Text = proxy.SayHello(txtName.Text); } catch (TimeoutException ex) { lblMsg.Text = ex.ToString(); proxy.Abort(); } catch (Exception ex) { lblMsg.Text = ex.ToString(); proxy.Abort(); } } }