i am trying to implement a access rules to my website. what im trying to figure out is how to set a default role for my main createuserwizard control on my default page. i want to set it to role type "customer" as default.
problem is i cant figure out how to make it work.
i tried a simple event-based code to capture the user name and tie it onto a role:
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 15, 2009, 9:01 PM EST
Try this.
protected void Page_Load(object sender, EventArgs e)
{
if (!Roles.RoleExists("customer"))
{
Roles.CreateRole("customer");
}
}
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Roles.AddUserToRole(CreateUserWizard1.UserName, "customer");
}
If you find this answer useful, please do not forget to mark this as accepted.