Change DIV style according to FORM

2

I have the following application to login

public ActionResult Logar(String Login, String Senha)
{
    var bdUsuario = ClientesAplicacaoConstrutor.ClientesAplicacaoEF();
    var usuario = bdUsuario.ListarTodos().Where(x => x.Codigo == Login && x.Senha == Senha);

    if (usuario.Count() == 1)
    {
        var user = usuario.First();
        FormsAuthentication.SetAuthCookie(user.ID.ToString(), false);
    }
    return RedirectToAction("Index");
}

The entire form is inside a formLogin ID div.

I would like to add the login condition a way to change the display of the div formLogin and consecutively display other content after the user logs in.

As the Controller can not find the ID of the div element, I tried with Panel and Literal with the tag runat="server" but even then I could not find my div so I change the CSS properties. / p>     

asked by anonymous 07.07.2014 / 15:26

1 answer

2

In your View you will have to use a if like this:

@if (Request.IsAuthenticated && User.Identity.IsAuthenticated)
{
    //logado                  
}
else
{
    //não logado                   
}
Remember that you do not now have the runat="server" tag because it is MVC and not WebForms >.

    
07.07.2014 / 15:35