I have my login screen and want to show the name is the user id logged on another screen, so I can use this information.
In my controller :
[HttpPost]
public ActionResult Index(TB_USUARIO model)
{
//aqui vai pesquisar o login é senha
try
{
var tbuscar = new UsuarioAplicacao();
var retorno = tbuscar.ListarPorLoginSenha(model.login, model.senha);
if (retorno != null)
{
ViewBag.Login = retorno.login;
ViewBag.senha = retorno.senha;
ViewBag.nome = retorno.nomeusuario;
ViewBag.id = retorno.idusuario;
return RedirectToAction("index", "MenuPrincipal");
}
else
{
TempData["Erro"] = "Usuário não localizado.";
}
ModelState.Clear();
}
catch (Exception ex)
{
TempData["Erro"] = ex.Message;
}
return View();
}
}
I want to show you this information:
@{
ViewBag.Title = "Index";
}
@section menu{
<!-- NAVBAR
================================================== -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">opciones de menú</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/Home"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>
<!-- NAVBAR FIM
================================================== -->
}
<br/>
<div class="panel panel-default">
<div class="panel-heading">Controle: @TempData["id"]</div>
<div class="panel-heading">Nome: @TempData["nome"] </div>
</div>