Hi, I am using an Email activation once a new user signed up for my website, after the mail sending is successful, how do I do a redirect to my verification email send success page?
protected void RegisterUser_CreatedUser(object sender, EventArgs e)
{
FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
string continueUrl = RegisterUser.ContinueDestinationPageUrl;
if (String.IsNullOrEmpty(continueUrl))
{
}
MembershipUser user = Membership.GetUser(RegisterUser.UserName);
// Get created user's UserId to store additional info
Guid userId = Helpers.AccountHelper.getUserGuId(user);
var dba = new DatabaseAccess();
SqlConnection c = dba.OpenConnection();
SqlCommand cmd = dba.SetupConnection("Add_Member", c);
cmd.Parameters.AddWithValue("@UserId", userId);
cmd.Parameters.AddWithValue("@Name", ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Username")).Text);
cmd.ExecuteNonQuery();
c.Close();
// *IMPORTANT *********************
//Roles.AddUserToRole(RegisterUser.UserName, "Users");
Session["UserName"] = RegisterUser.UserName;
// send the newly registered user a notification email
// send email to newly registered user
// MembershipUser newUser = Membership.GetUser(RegisterUser.UserName);
// Code to send email comfirmation
}
protected void RegisterUser_SendingMail(object sender, MailMessageEventArgs e)
{
// Set MailMessage fields.
e.Message.IsBodyHtml = false;
e.Message.Subject = "Welcome to My Website!";
// Replace placeholder text in message body with information
// provided by the user.
// Get the UserId of the just-added user
MembershipUser newUser = Membership.GetUser(RegisterUser.UserName);
Guid newUserId = (Guid)newUser.ProviderUserKey;
string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) +
Request.ApplicationPath;
string verifyUrl = "Account/NewUserVerification.aspx?ID=" + newUserId.ToString();
string fullUrl = urlBase + verifyUrl;
// Replace <%VerificationUrl%> with the appropriate URL and querystring
e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", fullUrl);
}
Ok, thanks, an error prevented me from seeing the default success page earlier on and somehow stayed on the page after the email was being sent, but how do I overwrite this default success page:
k80sg
Member
310 Points
340 Posts
New user Registration email send success redirection
Dec 20, 2012 02:59 PM|LINK
Hi, I am using an Email activation once a new user signed up for my website, after the mail sending is successful, how do I do a redirect to my verification email send success page?
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { } MembershipUser user = Membership.GetUser(RegisterUser.UserName); // Get created user's UserId to store additional info Guid userId = Helpers.AccountHelper.getUserGuId(user); var dba = new DatabaseAccess(); SqlConnection c = dba.OpenConnection(); SqlCommand cmd = dba.SetupConnection("Add_Member", c); cmd.Parameters.AddWithValue("@UserId", userId); cmd.Parameters.AddWithValue("@Name", ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Username")).Text); cmd.ExecuteNonQuery(); c.Close(); // *IMPORTANT ********************* //Roles.AddUserToRole(RegisterUser.UserName, "Users"); Session["UserName"] = RegisterUser.UserName; // send the newly registered user a notification email // send email to newly registered user // MembershipUser newUser = Membership.GetUser(RegisterUser.UserName); // Code to send email comfirmation } protected void RegisterUser_SendingMail(object sender, MailMessageEventArgs e) { // Set MailMessage fields. e.Message.IsBodyHtml = false; e.Message.Subject = "Welcome to My Website!"; // Replace placeholder text in message body with information // provided by the user. // Get the UserId of the just-added user MembershipUser newUser = Membership.GetUser(RegisterUser.UserName); Guid newUserId = (Guid)newUser.ProviderUserKey; string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath; string verifyUrl = "Account/NewUserVerification.aspx?ID=" + newUserId.ToString(); string fullUrl = urlBase + verifyUrl; // Replace <%VerificationUrl%> with the appropriate URL and querystring e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", fullUrl); }cornball76
Participant
1126 Points
210 Posts
Re: New user Registration email send success redirection
Dec 20, 2012 05:12 PM|LINK
Response.Redirect or Server.Transfer???
Am I missing something big here?
k80sg
Member
310 Points
340 Posts
Re: New user Registration email send success redirection
Dec 20, 2012 05:23 PM|LINK
But wouldn't redirect take place while the email is still being sent?
cornball76
Participant
1126 Points
210 Posts
Re: New user Registration email send success redirection
Dec 20, 2012 06:45 PM|LINK
The process is occuring in the same thread right? Unless you have some code that I don't see....
It will send the email then redirect.
k80sg
Member
310 Points
340 Posts
Re: New user Registration email send success redirection
Dec 21, 2012 06:56 AM|LINK
Ok, thanks, an error prevented me from seeing the default success page earlier on and somehow stayed on the page after the email was being sent, but how do I overwrite this default success page: