protected void btnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { if (HttpContext.Current.User.Identity.IsAuthenticated) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Warning", "alert('You already Registered!');", true); } ; var webService = new WebService.SiteCoreWebServiceSoapClient(); var date = DateTime.Now; var password = Cryptographer.GenerateSignature(txtPassword.Text); var valid = webService.Register(txtUserName.Text, password, date.ToString("yyyy-MM-ddTHH:mm:ss"), Cryptographer.GenerateSignature(txtUserName.Text + password + date.ToString("yyyy-MM-ddTHH:mm"))); if (valid) { FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Warning", "alert('Fail to Register!');", true); } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if (HttpContext.Current.User.Identity.IsAuthenticated) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Warning", "alert('You already Login!');", true); } ; var webService = new WebService.SiteCoreWebServiceSoapClient(); var date = DateTime.Now; var valid = webService.Login(Login1.UserName, Cryptographer.GenerateSignature(Login1.Password), date.ToString("yyyy-MM-ddTHH:mm:ss"), Cryptographer.GenerateSignature(Login1.UserName + Login1.Password + date.ToString("yyyy-MM-ddTHH:mm"))); if (valid) { FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true); } }