Thursday, February 12, 2009

How to Set A Default Role While Registration Itself

  • This will be possible only if we have aspnet tables and stored procedures in our database.
  • We should have users,roles in our application.
  • Now in our visual studio we will have a register page from which a new user will get registered in our website.
  • In this Register Page,register click we should include one line given below based on your requirement
  • Roles.AddUserInRole("String username","String rolename"); for single username adding ,if we want for a group of users then we can use the method named Roles.AddUsersInRole("String[] usersname","String rolename"); By this the total group given in the string array will be assigned the same role.
  • Here Roles is the aspnet class and AddUserInRole(),AddUsersInRoles() are methodes in that.
  • So with this line we can easily assign the role which we want the registring user to be assigned.

No comments: