Wierd ProviderException - email supplied is invalid

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?
 
V

VB Programmer

Hmmm I think the problem was the email address was a duplicate email
address.

Thanks y'all....
 
Y

Yves Tkaczyk

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,089
Latest member
Ketologenic

Latest Threads

Top