![]() |
[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 [:confused:] 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 |
Maybe you entered an e-mail address that is not in a valid format for an e-mail address?
BTW: no need to call ToString() on the Text property; it's already a string. Cheers, Imar |
Quote:
|
I did of course look at your notes,but the error is coming from the same code that comes with your code so it had to be in there somewhere. It's often a matter of eliminating problems.
Anyway, the problem is in the way you have configured the provider. I'm pretty sure that you have something like requiresUniqueEmail="true" in your web.config; either directly or by inheriting it from system files. Since this setup requires you to pass a (unique) e-mail address, you get your error when you don't supply an address at all. Simply set it to False and it should work. Hope this helps, BTW: were you able to solve the problems with the replies from Lee and me? Some follow up is always appreciated.... ;-) Imar |
Quote:
Well, the funny thing is that when I wasn't updating any email address this exception was being thrown, hence, the question. When I walked through the code the exception was being thrown by the Membership.CreateUser. I just did not understand why an invalid email exception was being thrown. With regards the Logon control and other replies they seem valid although I still have to go through the tutorials again :) |
Thanks Imar
Hi there, thanks Sir for your help.
I did faced the same problem. But I did not figured out that the requiresUniqueEmail was set to true. you were accurate. Great. (I am the same person who discussed the issue of Resources.axd with you) |
Maybe you entered an e-mail address that is not in a valid format for an e-mail address?
|
Yeah i guess that is t what the problem is...
|
All times are GMT -4. The time now is 04:58 AM. |
Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.