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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top