Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
This is the forum to discuss the Wrox book Professional ASP.NET 3.5: In C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470187579
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 13th, 2009, 10:43 AM
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
Reply With Quote
  #2 (permalink)  
Old March 14th, 2009, 02:40 PM
Imar's Avatar
Wrox Author
Points: 67,332, Level: 100
Points: 67,332, Level: 100 Points: 67,332, Level: 100 Points: 67,332, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,231
Thanks: 66
Thanked 1,418 Times in 1,398 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old March 14th, 2009, 04:47 PM
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

Quote:
Originally Posted by Imar View Post
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
Umm...don't think so. The form prompted me for a username/password. See my notes..
Reply With Quote
  #4 (permalink)  
Old March 15th, 2009, 05:19 AM
Imar's Avatar
Wrox Author
Points: 67,332, Level: 100
Points: 67,332, Level: 100 Points: 67,332, Level: 100 Points: 67,332, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,231
Thanks: 66
Thanked 1,418 Times in 1,398 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old March 15th, 2009, 07:58 AM
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

Quote:
Originally Posted by Imar View Post
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

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 :)
Reply With Quote
  #6 (permalink)  
Old January 11th, 2012, 04:56 PM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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)
Reply With Quote
  #7 (permalink)  
Old March 11th, 2013, 10:35 PM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe you entered an e-mail address that is not in a valid format for an e-mail address?
Reply With Quote
  #8 (permalink)  
Old July 20th, 2013, 01:15 AM
Authorized User
Points: 42, Level: 1
Points: 42, Level: 1 Points: 42, Level: 1 Points: 42, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2013
Location: New York
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah i guess that is t what the problem is...
__________________
REI Coupon
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid argument supplied for foreach() codejockey Beginning PHP 4 September 24th, 2010 03:40 AM
warning..fetch_array(): supplied argument is not a valid msman88 MySQL 1 March 6th, 2009 06:11 AM
System.Web.HttpException: Invalid mail attachment kapi.goel C# 4 September 6th, 2007 02:48 AM
mailling list:mysql_num_rows(): supplied argument jamesz20 Beginning PHP 2 December 6th, 2006 10:45 AM
fwrite(): supplied argument is not a valid stream Adam H-W Beginning PHP 3 January 20th, 2006 01:09 AM



All times are GMT -4. The time now is 08:53 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.