0

I have my ID role as technician, so why doesn't User.IsInRole recognize it?

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        if (User.IsInRole("technician"))
        {
            Response.Redirect("tickets.aspx");
        }
        else
        {
            Response.Redirect("servicerecords.aspx");
        }
    }
}
MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89
Vincent
  • 1
  • 3
  • sorry sir i cant post image i dont have 10 reputation but i have set ID role as technician – Vincent Oct 02 '14 at 02:28
  • 1
    Are you using asp.net membership? If so, check `aspnet_UsersInRoles` table and see if there's a record with `UserId` equals your user id from `aspnet_Users` table and `RoleId` equals the technician role id from `aspnet_Roles` table – ekad Oct 02 '14 at 02:28
  • i have set the technician name an EmployeeID from the database, the EmployeeID is set to use as userID and set it as Role technician – Vincent Oct 02 '14 at 02:54
  • Have you read this: http://www.codeproject.com/Articles/281573/ASP-NET-Membership-and-Role-Provider ? – ekad Oct 02 '14 at 03:23
  • You have properly setup the membership tables and specified the role provider in the web.config correct? Also, the user has logged in correct? Also ensure that the Application Name for the providers hasn't been changed after you set the role ids for a user since that will reset things. Also make sure the application names for membership and role providers match. – Mark Fitzpatrick Oct 02 '14 at 04:30
  • My problem is solved. I want to show it to you guys but I cant post answers LOL :D – Vincent Oct 02 '14 at 10:03

0 Answers0