6
I put the [Authorize]
in my controllers and I inserted this code:
<authentication mode="Forms">
<forms loginUrl="/Login/Login" />
</authentication>`
For whenever the 401 code occurs it redirect to the login page, however I do not know how to controller LOGIN
to grant access to a person.
My problem is this, it redirects to login, however when login it remains without access, probably missing something in 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");
}
}
}
How so inform? If the user accesses it is already authorized, no?
– Randrade
I could not understand very well what you meant. Could you elaborate your question better? It would also be interesting for you to improve this title to make it more specific, it will make it easier for other users to find your question if they have the same question.
– Zignd