title: MVC Custom Membership Provider and AccountController.cs
body: <p>I have implemented my own custom MembershipProvider, configured it within web.config and my initialize method is successfully being called, even though it only contains:</p>
  
  <pre><code>    public override void Initialize(string name, NameValueCollection config)
      {
          base.Initialize(name, config);
      }
  </code></pre>
  
  <p>I have also implemented all the other standard methods like:</p>
  
  <pre><code>    public override bool ChangePassword(string username, string oldPassword, string newPassword)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    public override bool ValidateUser(string username, string password)
  </code></pre>
  
  <p>My understanding of the benefits of bothering to write a custom MembershipProvider was that once you've implemented the interface and initialized it, the appropriate methods would automatically get called at the appropriate times by the standard MVC 5 web site. I.e. when a user logs in or registers etc. But none of my methods are being called, apart from Initialize()...</p>
  
  <p>Am I expected to have to go through the standard AccountController.cs and change all of the methods in there to force it to call my custom MembershipProvider?</p>
  
  <p>E.g. this is the standard Login() method:</p>
  
  <pre><code>    public async Task&lt;ActionResult&gt; Login(LoginViewModel model, string returnUrl)
      {
          if (ModelState.IsValid)
          {
              var user = await UserManager.FindAsync(model.Email, model.Password);
              if (user != null)
              {
                  await SignInAsync(user, model.RememberMe);
                  return RedirectToLocal(returnUrl);
              }
              else
              {
                  ModelState.AddModelError("", "Invalid username or password.");
              }
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>
  
  <p>Do I have to modify this to make sure its calling my stuff?</p>
  
  <p>Or what am I missing?</p>
  
  <p>Thanks.</p>