.net mvc email as username returning error - InvalidProviderUserKey
I have a .Net MVC application that I am trying to use an email address as the username. I implemented the logic from this article where the username is masked as the email. However, when I try to call
private readonly MembershipProvider _provider;
MembershipCreateStatus status;
_provider.CreateUser(userName, password, email, null, null, true, false, out status);
where the username is "email@email.com", the status always returns as InvalidProviderUserKey. If i use a standard username (without the @), it works fine. I tried searching for a solution but i can really find an explanation of InvalidProviderUserKey anywhere.
I was wondering if so开发者_JS百科meone has run into this problem before or might be able to offer an explanation of why this scenario would be returning this specific status. Thanks in advance for any help.
UPDATE
I used Guid.NewGuid for the ProviderUserKey and it worked.
_provider.CreateUser(userName, password, email,null, null, true, Guid.NewGuid(), out status);
Thank you Daniel A. White for your help. The article link that you provided was what I needed to understand it.
Make sure you pass something to providerUserKey
, not just false
.
providerUserKey
Type:System.Object
The unique identifier from the membership data source for the user.
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.createuser.aspx
精彩评论