views:

455

answers:

3

I need to implement the common 'New Account' pattern (in .net MVC) where:

  1. user information is collected;
  2. my system sends an email;
  3. and the user if required to reply to the email to activate the account.

Is there a best practices recognized or sample site that can guide my way?

thx much

EDIT: Note that i'm trying to drill into a deeper pattern here than just comparing a submitted password against a stored password.

Also please note that I'm not attempting any reference to Windows Workflow here. The title uses workflow in a generic sense only.

thx

A: 

Curious: Why not use the .NET membership providers? Haven't had the chance to use them myself yet, but I'm pretty sure they provide this functionality.

synhershko
I'm simply reluctant to buy into another MS subsystem. Part of the reason I'm opting for MVC in the first place is how nice it plays with jQuery. I was not a fan of web forms.But I'll have a look at jw's step-by-step and see how i feel about it then. thx
justSteve
I understand - I tend to use open-source technologies over MS where possible as well, however their Membership API is quite decent and extensible. Don't forget it could be extended easily - just google for "Custom .net membership API" (for example: http://www.devx.com/asp/Article/29256). Worst case, you'll find yourself coding your own extensible membership framework; that shouldn't take long too if you know your way around .net.
synhershko
justSteve: If you don't want to buy into another MS subsystem, why are you choosing to buy into a whole new framework (WorkFlow)? The membership provider is really easy to implement and you can easily derive new classes from the AspNetMembershipProvider class to implement new functionality. Frankly, this is more "ASP.NETy" than using WF.
Richard Clayton
+1  A: 

Here is a step by step blog to use asp.net mvc with its built-in membership api. I find it is pretty helpful.

J.W.
I'm not seeing any things about my reference to sending the registrant an email with a link to activate new account.
justSteve
+2  A: 

Implementing a Membership Provider

MSDN Membership Provider

Overriding a method, say the Create User Method

MSDN Membership.CreateUser()

All you need to do is inherit the AspNetMembershipProvider, override the CreateUser method and implement custom code:

public class MyNewMembershipProvider : AspNetMembershipProvider
{
        public override MembershipUser CreateUser(
            string username,
            string password,
            string email,
            string passwordQuestion,
            string passwordAnswer,
            bool isApproved,
            Object providerUserKey,
            out MembershipCreateStatus status)

            //Do whatever you need to do
            SendUserValidationMessage(emailAddress, responseMessage, 
                                      options, etc, whatever);

            return base.CreateUser(username, password, email, 
                                    passwordQuestion, passwordAnswer, 
                                    isApproved, providerUserKey, out status)
    }
}

I hope this helps. I think WF may be too much for something like this.

Richard Clayton