2
I’m creating an app where I use Windows Authentication for validation of user data. As soon as the application opens, some information from that logged-in user already appears on the first page. In another menu I open all registered users.
How to click the user and open the same page that opens when I enter the application, only with the data of that user I clicked?
That’s the Index
of my PerfilController
which is where I get the information through windows authentication that I want to present as soon as the user logging in enters the application:
public ActionResult Index()
{
var chapa = UserDetails.GetChapa(User.Identity.Name);
var perfil = db.Perfis.FirstOrDefault(x => x.Chapa == chapa);
if (perfil == null)
{
return HttpNotFound();
}
ViewBag.Id = perfil.Id;
return View(perfil);
}
This is the view Relatorio
I have where returns the list and position of the people I have registered at the bank. I wanted to click on "View Profile" and open the profile of that person I clicked on.
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Chapa)
</td>
<td>
@Html.DisplayFor(modelItem => item.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.Cargo)
</td>
<td>
@* @Html.ActionLink("Edit", "Edit", new { id=item.Id }) *@|
@Html.ActionLink("Ver Perfil", "Details", new { id=item.Id }) |
@* @Html.ActionLink("Delete", "Delete", new { id=item.Id })*@
</td>
</tr>
}
You already have some code implemented to have a starting point?
– Leonel Sanches da Silva
public Actionresult Index() { var chapa = Userdetails.Getchapa(User.Identity.Name); var perfil = db.Perfis.Firstordefault(x => x.Chapa == chapa); if (perfil == null) { Return Httpnotfound(); } Viewbag.Id = profile. Id; Return View(profile); }
– Victor
This is the index of my profile where I get the information I want to present as soon as the user enters the application
– Victor
Can you put this comment in your question? Click
editar
just below the question and add the code. Don’t forget that to put code in the question, put 4 spaces at the beginning of the line to differentiate.– Leonel Sanches da Silva
Okay, I put it there. I’m sorry it’s the first time I’m asking here.
– Victor
Okay, no problem. I’ll guide you.
– Leonel Sanches da Silva