title: ASP.Net Membership (Visual Studio 2012 & Web Forms)
body: <p>I'm using the Membership Provider (Precursor to Identity) in a WebForms Project. I was able to get the users working right out of the box. I registered a few users and ASP.Net created the following tables in my database.</p>
  
  <pre><code>dbo.Memberships
  dbo.Profiles
  dbo.Rules
  dbo.Users
  dbo.UsersInRoles
  dbo.UsersOpenAuthAccounts
  dbo.UsersOpenAuthData
  </code></pre>
  
  <p>I'm pretty sure that is the entire group of tables required for Membership. I have successfully Restricted access to my site to logged in users. I have created Roles and started  to get sections of the site DEFINED IN THE PAGES ITSELF restricted to users with certain roles. </p>
  
  <p>MY PROBLEM IS ADDING ADDITIONAL FIELDS FOR THE USER.</p>
  
  <p>So far I have went the route of simply adding the additional info to the profiles section of my web.config file. I currently have the following defined in my web.config:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="/Account/Login.aspx" timeout="2880" defaultUrl="~/Projects.aspx" /&gt;
  &lt;/authentication&gt;
  &lt;authorization&gt;
    &lt;deny users="?" /&gt;
    &lt;deny roles="Admin" /&gt;
  &lt;/authorization&gt;
  &lt;profile defaultProvider="SqlProvider"&gt;
    &lt;providers &gt;
      &lt;add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" /&gt;
    &lt;/providers&gt;
    &lt;properties&gt;
      &lt;add name="fname" /&gt;
      &lt;add name="lname" /&gt;
      &lt;add name="skype" /&gt;
      &lt;add name="phone" /&gt;
    &lt;/properties&gt;
  &lt;/profile&gt;
  &lt;membership defaultProvider="DefaultMembershipProvider"&gt;
    &lt;providers&gt;
      &lt;add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /&gt;
    &lt;/providers&gt;
  &lt;/membership&gt;
  &lt;roleManager enabled="true" defaultProvider="DefaultRoleProvider"&gt;
    &lt;providers&gt;
      &lt;add connectionStringName="DefaultConnection" applicationName="/" name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
    &lt;/providers&gt;
  &lt;/roleManager&gt;
  </code></pre>
  
  <p>So with that in place and the main change being that I added the following in order to try and add additional user related fields:</p>
  
  <pre><code>&lt;profile defaultProvider="SqlProvider"&gt;
    &lt;providers &gt;
      ...
    &lt;/providers&gt;
    &lt;properties&gt;
      &lt;add name="fname" /&gt;
      &lt;add name="lname" /&gt;
      &lt;add name="skype" /&gt;
      &lt;add name="phone" /&gt;
    &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>I also updated the <strong>Accounts/Register.aspx</strong> page and it now looks like this:</p>
  
  <pre><code>&lt;%@ Page Title="Register" Language="C#" MasterPageFile="~/DashUser.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="ArchiTrak.Account.Register" %&gt;
  
  &lt;asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="BodyContent"&gt;
  
          &lt;h2 class="form-signin-heading raleway"&gt;&lt;%: Title %&gt;.&lt;/h2&gt;
  
  &lt;asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatedUser="RegisterUser_CreatedUser"&gt;
      &lt;LayoutTemplate&gt;
          &lt;asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" /&gt;
          &lt;asp:PlaceHolder runat="server" ID="navigationPlaceholder" /&gt;
      &lt;/LayoutTemplate&gt;
      &lt;WizardSteps&gt;
          &lt;asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep"&gt;
              &lt;ContentTemplate&gt;
  
              &lt;div class="container"&gt;
  
                  &lt;div class="row"&gt;
                      &lt;div class="col-md-6"&gt;
                      &lt;p class="raleway"&gt;
                          Passwords are required to be a minimum of &lt;%: Membership.MinRequiredPasswordLength %&gt; characters in length.
                      &lt;/p&gt;
  
                      &lt;p class="validation-summary-errors"&gt;
                          &lt;asp:Literal runat="server" ID="ErrorMessage" /&gt;
                      &lt;/p&gt;
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="UserName" placeholder="User Name"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
                          CssClass="field-validation-error" ErrorMessage="The user name field is required." /&gt;
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="fname" placeholder="First Name"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="fname"
                          CssClass="field-validation-error" ErrorMessage="The First Name field is required." /&gt;
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="lname" placeholder="Last Name"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="lname"
                          CssClass="field-validation-error" ErrorMessage="The Last Name field is required." /&gt;
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="phone" placeholder="Phone Number"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="phone"
                          CssClass="field-validation-error" ErrorMessage="The Phone field is required." /&gt;
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="skype" placeholder="Skype Account"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="skype"
                          CssClass="field-validation-error" ErrorMessage="The Skype field is required." /&gt;
  
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="Email" TextMode="Email" placeholder="Email"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="Email"
                          CssClass="field-validation-error" ErrorMessage="The email address field is required." /&gt;
  
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="Password" TextMode="Password" placeholder="Password"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="Password"
                          CssClass="field-validation-error" ErrorMessage="The password field is required."/&gt;
  
  
                      &lt;asp:TextBox class="form-control" runat="server" ID="ConfirmPassword" TextMode="Password" placeholder="Password"/&gt;
                      &lt;asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword"
                              CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The confirm password field is required." /&gt;
                      &lt;asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
                                       CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." /&gt;
  
                      &lt;br /&gt;
                      &lt;asp:Button runat="server" CommandName="MoveNext" Text="Register" CssClass="btn btn-lg btn-primary btn-block"/&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;/ContentTemplate&gt;
              &lt;CustomNavigationTemplate /&gt;
          &lt;/asp:CreateUserWizardStep&gt;
      &lt;/WizardSteps&gt;
  &lt;/asp:CreateUserWizard&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>I have added the additional fields to collect the first &amp; lastname, skype and phone number. But when I submit the Registration for a new user Nothing shows up in the profiles table in the database.</p>
  
  <p>The Register.aspx.cs looks like this:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using Microsoft.AspNet.Membership.OpenAuth;
  
  namespace ArchiTrak.Account
  {
      public partial class Register : Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
          }
  
          protected void RegisterUser_CreatedUser(object sender, EventArgs e)
          {
              FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false);
  
              string continueUrl = RegisterUser.ContinueDestinationPageUrl;
              if (!OpenAuth.IsLocalUrl(continueUrl))
              {
                  continueUrl = "~/Projects.aspx";
              }
              Response.Redirect(continueUrl);
          }
      }
  }
  </code></pre>
  
  <p>From what I read about the profile way of adding additional information is that it just worked with minimal modifications similar to what I have done above. AM I Missing something? Are there any GOOD tutorials that step by step go over this using Web Forms? I have been searching for information and tutorials So I have found the microsoft links on Roles &amp; Profiles. That s how I got this far. I'm use to Identity, but cannot use it in this project. Any help would be appreciated, or just a kick in the right direction.</p>