0

私の行動

[Authorize(Roles = "Admin")]
public ActionResult Index()
{
    using (var ctx = new _dbContext())
    {
        return View(ctx.UserProfiles.OrderBy(x => x.UserId).ToList());
    }
}

UserId と UserName でロールを表示したいのですが、どうすればいいですか??

更新: モデルを表示

public class AccountIndexViewModel
{
    public int UserId { get; set; }
    public string UserName { get; set; }
    public string Roles { get; set; }
}

意見

@using GoldCalculator.Models
@model IEnumerable<AccountIndexViewModel>
            @foreach (var user in Model)
            {
                <tr>
                    <td>@user.UserId</td>
                    <td>@user.UserName</td>
                    <td>@user.Roles</td>
                    <td> @Html.ActionLink("X", "Delete", new { id = @user.UserName }, new {  @class = "deletebtn"})</td>
                </tr>
            }

出力は System.String[] です

4

1 に答える 1