I put [Authorize]
in my controllers and entered this code:
<authentication mode="Forms">
<forms loginUrl="/Login/Login" />
</authentication>'
For every time code 401 occurs it redirects to the login page, but I do not know how to do in controller LOGIN
to assign access to person.
My problem is this, it redirects to the login, but when I log in it is still not accessible, there is probably something missing from my LOGIN.
Below is my Controller:
public ActionResult Home()
{
return View();
}
public ActionResult Login(Usuario usuario)
{
if (usuario.Nome == null)
{
return View();
}
else
{
var user = db.Usuario.Where(u => u.Nome == usuario.Nome && u.Senha.Equals(usuario.Senha)).First();
if (user.Nome.Equals(null))
{
ViewBag.Mensagem = "Usuário ou Senha Inválido, tente novamente!";
return View();
}
else
{
return RedirectToAction("Home");
}
}
}