Configure Microsoft.AspNet.Identity to allow email address as username

前端 未结 13 2021
时光取名叫无心
时光取名叫无心 2020-11-28 20:08

I\'m in the process of creating a new application and started out using EF6-rc1, Microsoft.AspNet.Identity.Core 1.0.0-rc1, Microsoft.AspNet.Identity.EntityFramework 1.0.0-rc

13条回答
  •  执笔经年
    2020-11-28 20:45

    If you are using ASP.Net webforms and are trying to accomplish this, simply open up your IdentityModels.vb/cs file and under Public Class UserManager, have it look as so:

    Public Class UserManager
    Inherits UserManager(Of ApplicationUser)
    
    Public Sub New()
        MyBase.New(New UserStore(Of ApplicationUser)(New ApplicationDbContext()))
        Users = store
        UserValidator = New UserValidator(Of ApplicationUser)(Me) With {.AllowOnlyAlphanumericUserNames = False}
    End Sub
    
    Public Property Users() As IUserStore(Of ApplicationUser)
        Get
            Return m_Users
        End Get
        Private Set(value As IUserStore(Of ApplicationUser))
            m_Users = value
        End Set
    End Property
    Private m_Users As IUserStore(Of ApplicationUser)
    
    End Class
    

提交回复
热议问题