Software Engineer Problem Solver

Leo Reading

One Moment, Please...

Find My Articles

Share This Page

B l o g

Blog

Leo Reading

Software Engineer and Problem Solver From the USA

Download Resume

My Blog A collection of technical and non-technical mishaps, achievements and stories.

Programming

Delay In Development

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

    if (!Roles.RoleExists("rolename"))

    {

         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"))

    {

        Roles.RemoveUserFromRole("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.

Leo Reading

Leo Reading is a US based software engineer and problem solver. Known as a jack of all trades and master of few, Leo is constantly learning new technology and expanding his understanding of all things 'nerd'

You Might Also Like

Creating Static Error Pages Dynamically in MVC

Ben Foster has a great article on setting up custom error pages in an MVC project that I typically refer to each time I create a new one.  Recently, I've finally decided to work smarter, not harder, by setting up my own MVC seed project.  Of course, this should include some pre-defined error pages.  Unfortunately, error pages aren't ...

Website Redesign!

I just finished up the first version of a website for a friend of mine (which I'm sure I'll blog about once the content is all uploaded), and I started looking at my online portfolio.  I have to admin, it's pretty weak.  I realized that this site was the first site I made on my own after I started developing, and there'...

One Moment, Please

Close