MembershipCreateUserException - 提供的用户名无效 [英] MembershipCreateUserException - The username supplied is invalid

查看:174
本文介绍了MembershipCreateUserException - 提供的用户名无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这行我得到一个例外 -

On this line i am getting an exception -

OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);

System.Web.Security.MembershipCreateUserException:提供的用户名无效

System.Web.Security.MembershipCreateUserException: The username supplied is invalid.

数据进入,这是


  • 提供商 - 脸谱

  • providerUserId - 1321311387573991

  • model.UserName - 马克思·佩恩

初​​始化使用正常工作

The initialization works fine using

WebSecurity.InitializeDatabaseConnection("club", "User", "UserID", "UserName", autoCreateTables: true);

我找不到为什么它说用户名无效的例子?
是否有一个定义,什么是正确的用户名?一个地方标准

I cannot find any examples of why it says the username is invalid? Is there a criteria somewhere that defines what is a correct user name?

推荐答案

我也同样找一个解释这一点。我不知道我完全理解,但试验,调试,看的IntelliTrace事件之后,似乎CreateOrUpdateAccount创建或更新在OAuthMembership表只是提供者,ProviderUserId和用户ID的条目是通过查询[我的情况决定]的用户配置表在此基础上唯一的用户名。这样,如果你调用CreateOrUpdateAccount与不同的供应商和providerUserId,但相同的用户名,那么这两个供应商的标志插件会被连接到相同的用户帐户在您的应用程序。

I was similarly looking for an explanation to this. I'm not sure I fully understand, but after experimentation, debugging, and watching intellitrace events, it seems CreateOrUpdateAccount is creating or updating an entry in the OAuthMembership table with just Provider, ProviderUserId, and UserId which is determined by querying [in my case] the UserProfile table based on this unique UserName. This way, if you call CreateOrUpdateAccount with a different provider and providerUserId, but the same username, then both provider sign ins are tied to the same user account in your app.

我不得不添加一个用户配置之前,我可以创建/更新相应的OAuthMembership记录。在VS模板,它看起来是这样的:

I had to add a UserProfile before I could create/update the corresponding OAuthMembership record. In the VS template, it looked something like this:

db.UserProfiles.Add(new UserProfile { UserName = model.UserName }); 
db.SaveChanges();

OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);

这篇关于MembershipCreateUserException - 提供的用户名无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆