This project is read-only.

Default Role on registeration

Topics: Business Logic Layer
Jun 16, 2010 at 12:50 PM

As soon as user regsiter i want default role to be Editors.

How do i do that?

I tried doing this on Account/Register.aspx page

but it doesn't seem to be working.

Roles.AddUserToRole(RegisterUser.UserName, "Editors");

Jun 16, 2010 at 1:44 PM

Are you adding your code in the right place? The following works.

protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        Roles.AddUserToRole(RegisterUser.UserName, "Editors");
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

        string continueUrl = RegisterUser.ContinueDestinationPageUrl;
        if (String.IsNullOrEmpty(continueUrl))
            continueUrl = "~/";
Jun 16, 2010 at 3:09 PM

It's working now. I was adding it at wrong place. Thank you.