<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>Morten Bock</title><link>http://www.mortenbock.dk/</link><description>A feed of new content on my website</description><item><author>Morten Bock</author><category>english</category><category>umbraco</category><category>aspnet</category><category>membership</category><category>runway</category><description>
&lt;p&gt;I played around with the membership features of Umbraco tonight,
and I thought I would share my findings. Mostly because it is just
incredibly easy to do without even compiling any code. Just pure
templates and a single entry in the web.config file is all it
takes.&lt;/p&gt;

&lt;p&gt;I started by installing the Runway package, to get a basic
website.&lt;/p&gt;

&lt;p&gt;First of all, I set up my members area with a member type and a
member group:&lt;/p&gt;

&lt;p&gt;&lt;a href="/media/images/image.png"&gt;&lt;img src="/media/images/image-thumb.png" width="170" height="172" alt="image" border="0" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px"/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I need to tell asp.net which Member Type I want to use when
creating new users. Find this line in the web.config file:&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;pre&gt;
&amp;lt;add name="UmbracoMembershipProvider"
  type="umbraco.providers.members.UmbracoMembershipProvider"
  enablePasswordRetrieval="false"
  enablePasswordReset="false"
  requiresQuestionAndAnswer="false"
  defaultMemberTypeAlias="WebsiteUser"
  passwordFormat="Hashed" /&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Edit the attribute "defaultMemberTypeAlias" to the Member Type
you want. In my case it is "WebsiteUser".&lt;/p&gt;

&lt;p&gt;Now we are ready to create the Sign Up form. I do this in a new
template, which is just a copy of the Runway Textpage, but I add
the following after the body text:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;script runat="server"&amp;gt;

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
    Roles.AddUserToRole(CreateUserWizard1.UserName, "BasicUsers");
}

protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)
{
    Response.Redirect("/member-area.aspx");
}

&amp;lt;/script&amp;gt;

&amp;lt;asp:CreateUserWizard ID="CreateUserWizard1" OnContinueButtonClick="CreateUserWizard1_ContinueButtonClick" OnCreatedUser="CreateUserWizard1_CreatedUser" runat="server"&amp;gt;
    &amp;lt;WizardSteps&amp;gt;
        &amp;lt;asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"&amp;gt;&amp;lt;/asp:CreateUserWizardStep&amp;gt;
        &amp;lt;asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"&amp;gt;&amp;lt;/asp:CompleteWizardStep&amp;gt;
    &amp;lt;/WizardSteps&amp;gt;
&amp;lt;/asp:CreateUserWizard&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Inside the script block I react to two events. When the user is
created, I add him to the "BasicUsers" group, which is the one I
will give access to my members area. The other method simply
redirects the user to the member area when he finishes the signup
wizard. (&lt;strong&gt;EDIT:&lt;/strong&gt; Petr suggested that you use
ContinueDestinationPageUrl="/member-area.aspx" instead of the
redirect method, which I agree with)&lt;/p&gt;

&lt;p&gt;Now users can sign up for membership, but we also want them to
be able to log in. So we add this to the subNavigation div in the
Runway Textpage template:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;asp:LoginView ID="UmbracoLoginView" runat="server"&amp;gt;
    &amp;lt;AnonymousTemplate&amp;gt;
        &amp;lt;asp:Login ID="Login1" runat="server"&amp;gt;&amp;lt;/asp:Login&amp;gt;
    &amp;lt;/AnonymousTemplate&amp;gt;
    &amp;lt;LoggedInTemplate&amp;gt;
        Welcome
        &amp;lt;asp:LoginName ID="LoginName1" runat="server" /&amp;gt;
        &amp;lt;asp:LoginStatus ID="LoginStatus1" runat="server" /&amp;gt;
    &amp;lt;/LoggedInTemplate&amp;gt;
&amp;lt;/asp:LoginView&amp;gt;
&lt;/pre&gt;

&lt;p&gt;That is all the code that is needed. All that is left is
creating content:&lt;/p&gt;

&lt;p&gt;&lt;a href="/media/images/image1.png"&gt;&lt;img src="/media/images/image-thumb1.png" width="232" height="226" alt="image" border="0" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px"/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The login page is just a textpage with some text about logging
in. The Sign Up page is using my new template with the
CreateUserWizard control on it. The Member Area page has Public
Access set like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="/media/images/image2.png"&gt;&lt;img src="/media/images/image-thumb2.png" width="244" height="223" alt="image" border="0" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px"/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is all there is to it. Pretty easy huh? Feel free to post
any questions in the comments, and I will try and answer to the
best of my ability.&lt;/p&gt;
</description><guid isPermaLink="false">1394</guid><link>http://www.mortenbock.dk/blog/2009/04/01/setting-up-membership-in-umbraco.aspx</link><pubDate>Wed, 01 Apr 2009 00:33:43 +0100</pubDate><title>Setting up membership in Umbraco</title></item></channel></rss>
