How great is this? I'm really impressed by these kids from Iowa...where were projects like this when I was in third grade!
If you have some time, help them out by sending a quick email, last I checked they were up to about 5000 emails. Awesome, guys!
============================================
Dear Friends,
We are the third grade students from East Buchanan Elementary in
We are learning how email works in our computer
class. We are sending a message to see how many people it will reach
in our 30 day experiment. We will end our project on Monday, March
6th. Could you help us out? Share with us where you are from and
one neat place to visit from where you live. Then pass this message
on to as many people as you know. We are excited to map and graph
all of the different places our email will travel to. Thank you for
helping us with our project. Our email address is
eb3rdgraders@east-buc.k12.ia.us.
Check out our results at http://207.177.123.1/Staff/jb/e-mail.htm
Totals will be posted by March 30th, 2006.
Thank you again!
From the East Buchanan Third Grade Class
=====================================================
We'd noticed that our latest web app was creating two records in the aspnet_Application table, which was causing new users to be created twice, once for each applicationID. Obviously this isn't what we wanted, and the behavior started to create some mismatches between our data as records began to appear for the multiple IDs.
The solution was that we were not explicitly setting the applicationName property for each provider used. The machine.config file specifies that any provider whose applicationName is not set will default to the directory path, such as "/ClarityApp". Once we realized that our RoleManager provider was missing the property, I cleaned out the records and once again added my Roles and Users using the ASP.NET Configuration portal site, and presto, only one application record is created, with all providers referencing this applicationName.
I changed the applicationName to match across the providers, but you can also use separate app names in order to host multiple User/Roles sets within a database...you'd just need to include the current ApplicationID as a parameter in all of your stored procedures.
Here's a portion of our web.config:
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers >
<clear/>
<add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ManagerConnection"
applicationName="Clarity Test"
enablePasswordRetrieval="true"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="2"
passwordFormat="Encrypted"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider" applicationName="Clarity Test" type="System.Web.Security.SqlRoleProvider" connectionStringName="ManagerConnection"/>
</providers>
</roleManager>
I admit, after attending the Visual Studio 2005 Launch this fall and hearing that the .NET 2.0 framework would decrease the amount of code written by 70%, I was more than doubtful. My programmer snobbery kicked in, and I was instantly scoffing at this type of claim. From the clients and colleagues I've talked with, a lot of companies have adopted this type of thinking as well, and some are dragging their feet instead of starting to develop apps using the 2.0 Framework. Maybe its time to take another look...
One example I recently implemented really showed how 2.0 can live up to its bold claims. Working with ASP.NET 2.0's Membership and Roles classes really made user management simple...here's a quick sample of how I can add new users, validate their credentials, add (or remove) them to roles, and authenticate them...all in very little code:
private void CreateNewMarketingUser(string username, string password, string email)
{
// Create a new user
MembershipCreateStatus status;
Membership.CreateUser(username, password, email, DEFAULT_PASSWORD_QUESTION,
DEFAULT_PASSWORD_ANSWER, true, out status);
// Verify Creation
if (status != MembershipCreateStatus.Success)
{
// Creation failed
throw new Exception(status.ToString());
}
else
{
// Authenticate this user
if (Membership.ValidateUser(username, password))
{
// Add new user to desired role
if (Roles.RoleExists(CommonBase.ROLE_MARKETING))
{
Roles.AddUserToRole(username, _
CommonBase.ROLE_MARKETING);
}
// Success, redirect to originally desired destination
// (assuming user was bounced to this page
// for not being authenticated)
// This also adds the authentication cookie specified in
// web.config to user
FormsAuthentication.RedirectFromLoginPage( _
username, chkPersistentCookie.Checked);
}
else
{
// Validation failed
throw new Exception("A new user could not be validated.");
}
}
}
If you are new to Memberships and Roles, be sure to set up your SQL database to support these functionalities, by running the following command from your Visual Studio command prompt: aspnet_regsql. This will create the necessary database entities to support roles, memberships, personalization, profiles and more.
I found that applying these new techniques directly really enhanced my code and gave me all the flexibility I needed. 2.0 also comes with 7 new Login controls, which out of the box support login, password recovery, user status views, and more. These controls take advantage of the APIs described above, and can really get your app out of the gate quickly.