當使用包含連字符([email protected])的電子郵件註冊用戶時,用戶將以正確的角色正確登錄到數據庫,並將其分配給他。但是,當該用戶登錄到應用程序時,他看不到他的角色應該能夠看到的所有功能,f.x.一些按鈕或標籤。我沒有得到錯誤:註冊電子郵件中的ASP.NET連字符
User name [email protected] is invalid, can only contain letters or digits.
註冊時。
我AllowOnlyAlphanumericUserNames
設置爲false
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
}
,這適用於電子郵件包含一個點,而不是連字符([email protected]),用戶可以看到所有他的角色的用戶應能夠看到。
編輯
建議添加代碼到AccountController
按照this question問題仍然存在之後。
[ASP.NET MVC中帶有破折號的身份電子郵件]的可能重複(http://stackoverflow.com/questions/26726750/identity-email-with-dash-in-asp-net-mvc) – Liam