Wierd ProviderException - email supplied is invalid

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I have some code:

Dim u As MembershipUser
u = Membership.GetUser
u.Email = Me.txtEmail.Text
Membership.UpdateUser(u)

It's giving me this error:
ProviderException was unhandled by user code
The E-mail supplied is invalid

It's happening for the last line of code, UpdateUser.

u.Email is (e-mail address removed), so it is valid.

Sometimes this happens, sometimes it doesn't.

Any ideas why?
 
Repeat email addresses?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
 
Hmmm I think the problem was the email address was a duplicate email
address.

Thanks y'all....
 
The issue is that if you set the email address when it has not been changed, this error is raised. you have to conditionally set the email address with the MembershipUser only if it has changed.
Replace line

u.Email = Me.txtEmail.Text

with (sorry, c#)

if(u.Email.ToLower()!=Me.txtEmail.Trim().ToLower())
{
u.Email = Me.txtEmail.Text.Trim()
}

Once you do this, the UpdateUser call succeed. I would say this is a bug in the UpdateUser code.

Yves

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
 
Back
Top