0

I'm new at this, I'm using Visual Studio 2017 and I've been reading about ASP.NET Identity and membership providers but can't quite understand how to implement it correctly. I have a Web Application (ASP.NET 4.5, MVC 5.2) which was created as an empty project with no authentication, that connects with my database (MySQL) using Entity Framework with ADO.NET Entity Data Model (edmx file). What I want to do is to check the roles on this database and grant authorization to users based on them, what is the best way to do this? Here is my DB: MySQL Database

and my Authorize method in my controller (Login)

 [HttpPost]
    public ActionResult Authorize(contactos contactosModel)
    {



            using (proyectob_dbEntities db = new proyectob_dbEntities())
            {
                var contactoDetails = db.contactos.Where(x => x.rut == contactosModel.rut && x.password == contactosModel.password).FirstOrDefault();
                if (contactoDetails == null)
                {
                    contactosModel.LoginError = "Rut o Password incorrectos";
                    return View("Login", contactosModel);
                }
                else
                {

                    //FormsAuthentication.SetAuthCookie(contactosModel.rut, rememberMe = true);
                    Session["userID"] = contactoDetails.id;
                    return RedirectToAction("/Home", "Proyectob");
                }
            }

    }
Nada
  • 11
  • 2
  • 1
    Don't use `Session`, use `ClaimsIdentity`. – Dai Jul 24 '18 at 03:22
  • For MVC5 [here](https://stackoverflow.com/questions/31960433/adding-asp-net-mvc5-identity-authentication-to-an-existing-project) is a good start. – John White Jul 24 '18 at 19:09

0 Answers0