开发者

asp forms authentication

I've build a login page with users defined in asp.net web administration tool and I’m trying to give permissions depending on User Role I use this code

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") = "Recto开发者_开发问答r"

    End If

But the thing is, the User.IsInRole is empty because the User in not yet assigned to the the user who’s logging in.


In your web.config do you have a role manager defined? ex:

<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider"/>

see: http://msdn.microsoft.com/en-us/library/ff647401.aspx "Additional Considerations"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜