title: Simple Authentication in .net WebPages
body: <p>I am trying to authenticate through WebSecurity class.</p>
  
  <p>I have a form and when a user submits this is called:</p>
  
  <pre><code>@{
      if(IsPost) {
          var username = Request["username"];
          var password = Request["password"];
  
          WebSecurity.CreateAccount(username, password, false);
  
          WebSecurity.Login(username, password);
  
          Response.Redirect("Default.cshtml");
      }
  
  }  
  </code></pre>
  
  <p>I already call:</p>
  
  <pre><code>WebSecurity.InitializeDatabaseConnection("Veidibok", "UserProfile", "UserId", "Email", true);
  </code></pre>
  
  <p>in my _appStart.cshtml file.</p>
  
  <p>I get this error from the <code>CreateAccount()</code> call:</p>
  
  <blockquote>
    <p>[MembershipCreateUserException: The Provider encountered an unknown
    error.]<br>
    WebMatrix.WebData.SimpleMembershipProvider.CreateAccount(String
    userName, String password, Boolean requireConfirmationToken) +1312<br>
    WebMatrix.WebData.WebSecurity.CreateAccount(String userName, String
    password, Boolean requireConfirmationToken) +31<br>
    ASP._Page_Authentication_Register_cshtml.Execute() in
    c:\Users\Notandi\Documents\My Web
    Sites\VeidiBok\Authentication\Register.cshtml:6<br>
    System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207<br>
    System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1
    executors) +68    System.Web.WebPages.WebPage.ExecutePageHierarchy()
    +156    System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
    pageContext, TextWriter writer, WebPageRenderingBase startPage) +76<br>
    System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase
    httpContext) +119</p>
  </blockquote>
  
  <p>So anyone have any ideas? I'm really new at this, just trying out WebMatrix and .cshtml</p>