3
I have my screen login is to show the name is id of the logged in user 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 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>
And what is the doubt?
– Maniero
<div class="panel-Heading">Control:@Viewbag.name</div> is empty
– Harry
@bigown, I didn’t know I could vote, but I appreciate the reminder!
– Harry
You can vote for anything you think is cool on the site. And there’s a lot of cool stuff to vote for :)
– Maniero