954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Roles.IsUserInRole() can't get it work !!!

Using ASP.NET Web Admin tool, i created 5 users and assigned them to different roles, but when i try to user Roles.IsUserInRole, it doesn't work, please take a look here:

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        string username = Login1.UserName;
        string password = Login1.Password;

        if (!IsPostBack)
        {


            if (Membership.ValidateUser(username, password))
            {

                if (Roles.IsUserInRole("Saleman"))
                    Response.Redirect("~/Saleman.aspx");

                else if (Roles.IsUserInRole("Accountant"))
                    Response.Redirect("~/Accountant.aspx");

                else if (Roles.IsUserInRole("HR"))
                    Response.Redirect("~/HR.aspx");


                //Always receive Attempt to login failed message !!
            }
        }
    }
Yamazaki
Newbie Poster
15 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

Help plz. ...

Yamazaki
Newbie Poster
15 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

When you created each user did you approve their account? Make sure each user is in the 'approved' status, otherwise they won't validate.

iDeveloper
Light Poster
49 posts since Jul 2008
Reputation Points: 31
Solved Threads: 7
 

Yes they're Active users if that what you mean!

Yamazaki
Newbie Poster
15 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

up...

Yamazaki
Newbie Poster
15 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

Problem solved, incorrect syntax, i should use it like that:

Roles.IsUserInRole(string username, string rolename){}

Yamazaki
Newbie Poster
15 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You