Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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
  #2 (permalink)  
Old March 14th, 2009, 02:40 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
  #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..
  #4 (permalink)  
Old March 15th, 2009, 05:19 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
  #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 :)
  #6 (permalink)  
Old January 11th, 2012, 05: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)
  #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?
  #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


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 07: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 11:45 AM
fwrite(): supplied argument is not a valid stream Adam H-W Beginning PHP 3 January 20th, 2006 02:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.