【问题标题】:asp forms authenticationasp表单认证
【发布时间】:2011-05-08 10:15:06
【问题描述】:

我已经建立了一个登录页面,其中包含在 asp.net 网络管理工具中定义的用户和 我正在尝试根据用户角色授予权限 我用这个代码

Public Sub mainlogin_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles mainlogin.Authenticate

    If Membership.ValidateUser(mainlogin.UserName, mainlogin.Password) Then
        Dim usrInfo As MembershipUser = Membership.GetUser(mainlogin.UserName)
        Session("UsrName") = usrInfo.UserName

        If User.IsInRole("Deans") Then
            Session("UsrRole") = "Deans"

        ElseIf User.IsInRole("Rector") Then
            Session("UsrRole") = "Rector"

    End If

但问题是,User.IsInRole 是空的,因为尚未将 User in 分配给正在登录的用户。

【问题讨论】:

    标签: asp.net forms-authentication


    【解决方案1】:

    在您的 web.config 中是否定义了角色管理器? 例如:

    见: http://msdn.microsoft.com/en-us/library/ff647401.aspx “其他注意事项”

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 2012-08-03
    相关资源
    最近更新 更多