Reputation: 85096
I am trying to update the Comments for a user but when I try using the code below:
MembershipUser User = Membership.GetUser(UserName);
User.Comment = "Whatever...";
Membership.UpdateUser(User);
It throws the error:
The E-mail supplied is invalid.
I've checked the email right before I call UpdateUser
and it's fine. Can anyone see why this would be happening?
UPDATE:
Stack trace -
[ProviderException: The E-mail supplied is invalid.]
System.Web.Security.SqlMembershipProvider.UpdateUser(MembershipUser user) +1583
System.Web.Security.MembershipUser.Update() +111
Security_Login.btnSubmit_Click(Object sender, EventArgs e) in c:\inetpub\V1\VerbalInk.Web\Security\Login.aspx.cs:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
Upvotes: 1
Views: 1622
Reputation: 11554
There is possibly Duplicate Email Address
in database. if you set requiresUniqueEmail
to false
in Membership Connection String
, set it to true
.
<add name="AspNetSqlMembershipProvider" applicationName="blah"
connectionStringName="balh" enablePasswordReset="true" enablePasswordRetrieval="false"
maxInvalidPasswordAttempts="5" minRequiredNonalphanumericCharacters="0"
minRequiredPasswordLength="5" passwordAttemptWindow="15" passwordFormat="Hashed"
requiresQuestionAndAnswer="false" **requiresUniqueEmail="true"**
type="System.Web.Security.SqlMembershipProvider" />
Upvotes: 2
Reputation: 85096
This turned out to have been caused by there being another record in my aspnet_Membership table that had the same email address as the record I was trying to update. This is a testing database so I'm guessing I must have added it manually or something a while back, because with the current system it isn't possible to create duplicates.
For some reason they have a pretty misleading error message that suggests there is something wrong with the email address when, in fact, the issue is related to duplicate emails.
Hope this can help someone in the future.
Upvotes: 0