Posts
60
Comments
36
Trackbacks
18
Add User to Default Role, Asp.Net Memberships

Just a quick way to make a default role for everyone that signs up for your web site if you are using ASP.NET Memberships, with ASP.NET MVC.

First, add this to the top of your AccountController...

using DotNetRoles = System.Web.Security.Roles;

Then, you want to add this around line 105 of the same file.  Please note that in this example, I already have a role "Users" that I want everyone to default to.

DotNetRoles.AddUserToRole(userName, "Users");

Here is an image of the modified method.

2-7-2009 12-31-28 AM

After that, you are good to go.  Enjoy.

Technorati Tags: ,,
posted on Saturday, February 07, 2009 12:22 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 8 and 4 and type the answer here:
News
My Developer Notebook! This also happens to be my opinion place. Thanks for coming by.