View Single Post
  #1 (permalink)  
Old March 13th, 2009, 10:43 AM
jon80 jon80 is offline
Authorized User
Points: 66, Level: 1
Points: 66, Level: 1 Points: 66, Level: 1 Points: 66, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Default [newbie] The E-mail supplied is invalid ?

Listing 16-9

When I run this code I am getting an error:
Error: System.Web.Security.MembershipCreateUserException: The E-mail supplied is invalid. at System.Web.Security.Membership.CreateUser(String username, String password, String email) at System.Web.Security.Membership.CreateUser(String username, String password) at ASP.default_aspx.Button1_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\TestWebSite\Default.aspx:line 8



I realized that this was because there wasn't a specific 'catch' so, anyway the code was updated (ref. Pg.774).
...
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Membership.CreateUser(TextBox1.Text.ToString(), TextBox2.Text.ToString());
Label1.Text = "Successfully created user " + TextBox1.Text;
}
catch (MembershipCreateUserException ex)
{
Label1.Text = "Error: " + ex.ToString();

switch (ex.StatusCode)
{
case MembershipCreateStatus.InvalidEmail:
Label1.Text = "Error: " + "An invalid email address has been updated";
break;

}
}
}
...

However, I'm not sure why this particular exception is being thrown by Membership.CreateUser. Since I'm updating a username and a password.

...
Membership.CreateUser(TextBox1.Text.ToString(), TextBox2.Text.ToString());
...

Related links:
http://msdn.microsoft.com/en-us/libr...reateuser.aspx

Last edited by jon80; March 13th, 2009 at 01:37 PM. Reason: update #2