O'Reilly logo

Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB by Stefan Schackow, Bilal Haidar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.1. The Membership Class

Probably the first exposure many of you had to the Membership feature was through the similarly named Membership class. This class is defined as a public static class, and the style of programming you use with it is meant to parallel other common ASP.NET classes such as Request, Response, and so on. Rather than having to muddle around trying to figure out how to get up and running with the feature, the idea is that after developers know of the Membership class, they can quickly access the functionality of the feature.

As with many provider-based features, the most important task the Membership class provides has already completed before any of your code does anything substantial with the feature. The previous chapter, on the provider model, showed how a static feature class is responsible for initializing a feature, including the instantiation and initialization of all providers associated with the feature. Because the Membership class is static, it performs initialization only once during the lifetime of an application. Furthermore, it instantiates only one instance of each configured MembershipProvider. So, if you plan on writing custom MembershipProviders, you need to follow the guidelines from Chapter 10 to ensure that your custom providers are thread-safe in all public properties and methods.

Although the Membership class is static, for historical reasons (the Membership feature was implemented very early on in the development cycle of ASP.NET 2.0) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required