Customize Windows Authentication

2

I am creating an application where I use Windows Authentication to validate user data. As soon as the application opens, some information about that logged in user appears on the first page. In another menu I open all registered users.

How do I click on the user and open the same page that opens when I enter the application, but with the data of that user that I clicked?

This is the Index of my PerfilController which is where I get the information through the windows authentication that I want to display as soon as the user logs in to 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 that I have where the list returns and position of the people that I have registered in the bank. I wanted to click "View Profile" and open the profile of that person I clicked.

@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>
}
    
asked by anonymous 26.05.2014 / 22:13

1 answer

2

Make another Action , for example, Details , in its Controller :

public ActionResult Usuario(String userName)
{
    var chapa = UserDetails.GetChapa(userName);
    var perfil = db.Perfis.FirstOrDefault(x => x.Chapa == chapa);
    if (perfil == null)
    {
        return HttpNotFound();
    }

    ViewBag.Id = perfil.Id;
    return View(perfil);
}

Do not forget to create its View file, in this case, Details.cshtml .

To test, call at:

  

link

In% of Report, change the following:

<td>
   @* @Html.ActionLink("Edit", "Edit", new { id=item.Id }) *@|
    @Html.ActionLink("Ver Perfil", "Details", "Usuarios", new { userName = item.Nome }) |
   @* @Html.ActionLink("Delete", "Delete", new { id=item.Id })*@
</td>
    
26.05.2014 / 22:26