title: Perform Login action using ASP.NET MVC 5 with DocumentDB
body: <p>Is there anyone who has managed to make an application that perform a login action and keep the session of a user from a DocumentDB in asp.net mvc 5.
  I tried, but I didn't.
  I created a model MyUser.cs</p>
  
  <pre><code>public class MyUser
    {
  
      [JsonProperty(PropertyName = "id")]
      public string id { get; set; }
  
      [JsonProperty(PropertyName = "mail")]
      public string mail { get; set; }
  
      [JsonProperty(PropertyName = "password")]
      public string password { get; set; }
    }
  </code></pre>
  
  <p>A controller MyUserController</p>
  
  <pre><code>public class MyUserController : Controller
    {
      public ActionResult Index()
      {
        var client = DocumentDBRepository.InstantiatesClient();
        var database = DocumentDBRepository.ReadOrCreateDatabase("myDB");
        var collection = DocumentDBRepository.ReadOrCreateCollection(database.SelfLink, "myUsers");
        List&lt;Server_MVC5.Models.MyUser&gt; users = DocumentDBRepository.getMyUsers(collection);
        return View(users);
      }
  
      [HttpPost]
      [ValidateAntiForgeryToken]
      public async Task&lt;ActionResult&gt; Login([Bind(Include = "email,password")] Models.MyUser myuser)
      {
        if (ModelState.IsValid)
        {
          DocumentDBRepository.Login(myuser.mail, myuser.password);
          return RedirectToAction("Index");
        }
  
        return View(myuser);
      }
  
      public ActionResult Login(string email, string password)
      {
        if (email == null)
        {
          return HttpNotFound();
        }
  
        Models.MyUser myuser = DocumentDBRepository.Login(email, password);
        if (myuser == null)
        {
          return HttpNotFound();
        }
  
        return View("Index");
      }
    }
  </code></pre>
  
  <p>A view for login Login.cshtml</p>
  
  <pre><code>@using Server_MVC5.Models
  @model LoginViewModel
  @{
      ViewBag.Title = "Log in";
  }
  
  &lt;h2&gt;@ViewBag.Title.&lt;/h2&gt;
  &lt;div class="row"&gt;
      &lt;div class="col-md-8"&gt;
          &lt;section id="loginForm"&gt;
              @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
              {
                  @Html.AntiForgeryToken()
                  &lt;h4&gt;Use a local account to log in.&lt;/h4&gt;
                  &lt;hr /&gt;
                  @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(m =&gt; m.Email, new { @class = "col-md-2 control-label" })
                      &lt;div class="col-md-10"&gt;
                          @Html.TextBoxFor(m =&gt; m.Email, new { @class = "form-control" })
                          @Html.ValidationMessageFor(m =&gt; m.Email, "", new { @class = "text-danger" })
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(m =&gt; m.Password, new { @class = "col-md-2 control-label" })
                      &lt;div class="col-md-10"&gt;
                          @Html.PasswordFor(m =&gt; m.Password, new { @class = "form-control" })
                          @Html.ValidationMessageFor(m =&gt; m.Password, "", new { @class = "text-danger" })
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;div class="col-md-offset-2 col-md-10"&gt;
                          &lt;div class="checkbox"&gt;
                              @Html.CheckBoxFor(m =&gt; m.RememberMe)
                              @Html.LabelFor(m =&gt; m.RememberMe)
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;div class="col-md-offset-2 col-md-10"&gt;
                          &lt;input type="submit" value="Log in" class="btn btn-default" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;p&gt;
                      @Html.ActionLink("Register as a new user", "Register")
                  &lt;/p&gt;
                  @* Enable this once you have account confirmation enabled for password reset functionality
                      &lt;p&gt;
                          @Html.ActionLink("Forgot your password?", "ForgotPassword")
                      &lt;/p&gt;*@
              }
          &lt;/section&gt;
      &lt;/div&gt;
      &lt;div class="col-md-4"&gt;
          &lt;section id="socialLoginForm"&gt;
              @Html.Partial("_ExternalLoginsListPartial", new ExternalLoginListViewModel { ReturnUrl = ViewBag.ReturnUrl })
          &lt;/section&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p>I state that DocumentDBRepository is a repo that retrieve info from my DocumentDB Azure Db (it works properly).
  When I perform login, it returns ever failure despite the credentials are correct.
  Does anyone know how to help me ?</p>