0

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") = "Rector"

    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.

1 Answer 1

0

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"

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.