Why in the following Razor markup
@foreach (var item in Model) {
<tr>
<td>@Html.DisplayFor(modelItem => item.IncidentId)</td>
...
<td>
@Html.ActionLink("View", "View", new { id = item.IncidentId })
@Html.ActionLink("Edit", "Edit", new { id = item.IncidentId })
@{
if (User.IsInRole("Manager"))
{
Html.ActionLink("Remove", "Remove", new {id = item.IncidentId});
}
}
</td>
</tr>
}
event when the user is Manager (I can confirm that the RoleProvider works fine, since while debugging I can see how the debugger steps into the code to call Html.ActionLink for the Remove), an actual action link doesn’t get rendered into the resulting html?
If I just place
@Html.ActionLink("Remove", "Remove", new { id = item.IncidentId })
it gets rendered fine.
@{ }is a code block, values won’t get written to the response output by default.You could either do:
or: