0

I'm hosting a simple ASP.NET MVC5 Web Application on Azure and I'm using SimpleMembershipProvider to hand authentication.

Everything works fine on my local machine, but when I try to log in on the Azure application, WebSecurity.Login always returns false. No exceptions happen, and all of the UserProfiles appear in the database. I tried debugging my login method, but WebSecurity.Login is a bit of a black box, so I'm not sure why it's returning false.

 public ActionResult Login(Login loginData, string ReturnUrl)
    {       
        if (ModelState.IsValid)
        {
            if (WebSecurity.Login(loginData.Username, loginData.Password))
            {
                if (ReturnUrl != null)
                {
                    return Redirect(ReturnUrl);
                }
                return RedirectToAction("Index", "Home");
            }
        }
        ModelState.AddModelError("", "Sorry the username or password is incorrect");
        return View(loginData);
    }
  • did you check this question http://stackoverflow.com/questions/12254701/simplemembershipprovider-not-working?rq=1 – Aravind Jun 09 '16 at 08:39
  • I did. He's getting an exception, but mine just fails to log in, as if the password was incorrect. It has to be something really simple that I'm missing. – Kelvin Lacy Jun 09 '16 at 17:08

1 Answers1

0

After some research I've gotten it working. It seems that the password hash generated when I seeded the database from my development machine was different than the one calculated by the server. I'm not sure why that is, but the login function started working correctly once I called the CreateUser function on application start on the server, rather than from Update-Database on my development machine.