我正在尝试设置一些密码策略,我设法在C#中成功完成此操作,但我需要将代码转换为VB。有两个问题我无法弄清楚:
1)app.UseUserManagerFactory
不存在;
说明UseUserManagerFactory is not a member of Owin.IAppBuilder
2)实例化OnCreate
时Provider
属性未正确传递
Public Sub ConfigureAuth(app As IAppBuilder)
'Configure the UserManager
app.UseUserManagerFactory(New IdentityFactoryOptions(Of ApplicationUserManager)() With { _
.DataProtectionProvider = app.GetDataProtectionProvider(), _
.Provider = New IdentityFactoryProvider(Of ApplicationUserManager)() With { _
.OnCreate = ApplicationUserManager.Create _
} _
})
为了完整起见,这是Create
函数:
Public Shared Function Create(options As IdentityFactoryOptions(Of ApplicationUserManager))
Dim manager = New ApplicationUserManager(New ApplicationUserStore(New ApplicationDbContext()))
manager.UserValidator = New UserValidator(Of ApplicationUser)(manager) With {.AllowOnlyAlphanumericUserNames = False, .RequireUniqueEmail = True}
manager.PasswordValidator = New PasswordValidator()
Dim dataProtectionProvider = options.DataProtectionProvider
If (dataProtectionProvider IsNot Nothing) Then
' Do stuff
End If
Return manager
End Function
任何帮助都会受到赞赏,我的VB技能加上缺乏文档让我摸不着头脑。