Project Description
The starter kit provides the Asp.Net MVC controllers, models, and views needed to administer users & roles.
What is the Asp.Net MVC Membership Starter Kit?
The starter kit currently consists of two things:
- A sample website containing the controllers, models, and views needed to administer users & roles.
- A library that provides testable interfaces for administering users & roles and concrete implementations of those interfaces that wrap the built-in Asp.Net Membership & Roles providers.
Out of the box, the starter kit gives you the following features:
- List of Users
- List of Roles
- User Account Info
- Change Email Address
- Change a User's Roles
How do I use it?
In Asp.Net MVC 1 there isn’t a great story for packaging & sharing controllers, views, and other resources so we’ll need to follow a few manual steps:
- After getting the source code build it using your preferred IDE or using the included Build.Debug.bat or Build.Release.bat batch files.
- Grab the MvcMembership.dll assembly and place it wherever you’re including external libraries in your project. Add a reference to the assembly to your Asp.Net MVC application.
- Copy the UserAdministrationController.cs file from the SampleWebsite’s Controllers directory to your app’s Controllers directory.
- Copy the ISmtpClient.cs file, SmtpClientProxy.cs file, and UserAdministration folder from the SampleWebsite’s Models folder to your app’s Models folder.
- Copy the UserAdministration folder from the SampleWebsite’s Views folder to your app’s Views folder.
- Copy the MvcMembership folder from the SampleWebsite's Content folder to your app's Content folder.
- Run through the various .cs files and the views and change the namespaces from SampleWebsite.* to whatever is appropriate for your application.
- Make sure you’ve configured your web.config properly for Membership and Roles. If you aren’t sure of how to do this, take a look at the first two articles in this series by Scott Mitchell at 4GuysFromRolla.
- Finally, add the following code to your global.asax to keep the membership system updated with each user’s last activity date:
protected void Application_AuthenticateRequest()
{
if(User != null)
Membership.GetUser(true);
}
What is new since the last release?
Well, the last release was for
Preview 5, so at the very least the project has been updated for Beta and finally Release. Moreover, the project has been completely rewritten from scratch – a major undertaking that was the primary cause of the long delay between releases. Why the rewrite? Two reasons:
- The first release of the Starter Kit was for Preview 2 of the MVC framework. A lot changed between Preview 2 and Release – A LOT. A lot of the features of the first starter kit were rolled into the OTOB experience (such as login and registration), so I shifted the scope of the project more squarely into the realm of user & role administration. Unfortunately all of these major changes took a toll on the source – I was no longer happy working in the source as it was written for many reasons and thus wanted a rewrite. One of those reasons was…
- Previous releases had no (as in zero, less than one, nada) unit tests. This became increasingly unacceptable to me and trying to add unit tests after-the-fact was a nightmare. Instead I rewrote the project using TDD.
Alright, so that was basically the long-winded spiel to prepare you for the bad news: the project regressed from a functionality perspective. During the course of the rewrite things some things didn’t make it in – chief among them is the OpenID integration. I encourage everyone to take a look at the Maarten Balliauw (an MvcMembership contributor) blog post on
authenticating via RPX in MVC.