将以前的CustomRoleProvider升级到Asp.Net MVC 5中的新提供程序的最佳方法是什么。我刚刚实现了这些方法并推出了自己的表(因为它是一个多数据库Web应用程序)
升级我的身份验证的最简单,最快捷的方法是什么?
我之前的web.config
<roleManager enabled="true" defaultProvider="MyCustomRoleProvider" cacheRolesInCookie="true" createPersistentCookie="true">
<providers>
<clear />
<add name="MyCustomRoleProvider" type="FacturatieMVCv2.Web.Core.MyCustomRoleProvider" />
</providers>
</roleManager>
我的RoleProvider
Imports FacturatieMVCv2.Service
Imports FacturatieMVCv2.Domain.Common
Imports System.Web
Imports FacturatieMVCv2.Web.Core
Public Class MyCustomRoleProvider
Inherits System.Web.Security.RoleProvider
Dim _userService As Master.UserService
Public Sub New(ByVal UserService As Master.IUserService)
_userService = UserService
End Sub
Public Sub New()
End Sub
Public Overrides Sub AddUsersToRoles(usernames() As String, roleNames() As String)
End Sub
Public Overrides Property ApplicationName As String
Get
Return My.Application.Info.AssemblyName
End Get
Set(value As String)
End Set
End Property
Public Overrides Sub CreateRole(roleName As String)
Throw New NotImplementedException("UsesBitWiseOperations, change the ENUM Field")
End Sub
Public Overrides Function DeleteRole(roleName As String, throwOnPopulatedRole As Boolean) As Boolean
Throw New NotImplementedException("UsesBitWiseOperations, change the ENUM Field")
End Function
Public Overrides Function FindUsersInRole(roleName As String, usernameToMatch As String) As String()
Return _userService.FindUsersInRole(roleName, usernameToMatch).Select(Function(el) el.UserName)
End Function
Public Overrides Function GetAllRoles() As String()
Return _userService.GetAllRoles
End Function
Public Overrides Function GetRolesForUser(username As String) As String()
Return _userService.GetRolesForUser(username)
End Function
Public Overrides Function GetUsersInRole(roleName As String) As String()
Return _userService.GetUsersInRole(roleName).Select(Function(el) el.UserName)
End Function
Public Overrides Function IsUserInRole(username As String, roleName As String) As Boolean
Return _userService.IsUserInRole(username, roleName)
End Function
Public Overrides Sub RemoveUsersFromRoles(usernames() As String, roleNames() As String)
_userService.RemoveUsersFromRoles(usernames, roleNames)
End Sub
Public Overrides Function RoleExists(roleName As String) As Boolean
Return _userService.RoleExists(roleName)
End Function
End Class
答案 0 :(得分:0)
您需要摆脱roleManager
中membershipProvider
和web.config
的所有提及。新身份框架不是MembershipProvider
的直接更新。升级通常需要做很多工作。您是否看到this guide进行升级?