I had put a decent amount of time and effort into creating this website, but unfortunately it is still seriously lacking in the content department. While I've been meaning to update it, I've been spending every free moment I have working on a super top-secret project that I will be announcing soon. If you look through my other posts, you can probably guess that it involves a movile app. The other aspect of it is a fully functioning website to help support it.
In the past three weeks, I feel like I've learned more than I have in the 6 months prior! I did not have much, if any, experience with Aspnet Forms authentication until now. One of the most useful features is the built-in Role manager. Some of the most useful functions that I have found:
using System.Web.Security; // You need this reference to use the roles manager
public void foo(String UserName)
// Determine if a role exists
Role.CreateRole("rolename"); // Create the role
} // end if role does not exist
// Check if a user is currently in a given role
if (!Roles.IsUserInRole("username", "rolename"))
Roles.AddUserToRole("username", "rolename"); // Add a specific user to a specific role
} // end if user is not in role
// Check if the user is in a role to remove the user from the role
if (Roles.IsUserInRole("username", "rolename"))
} // end if user is in role
} // end foo
As much as I tend to bark at Microsoft, they really could not have made it any easier on us developers. Additionally, it's super easy to extend the Authorization Attribute class to handle unauthorized errors for specific roles, users, etc.