neel k

neel k

  • NA
  • 143
  • 132.6k

Show & hide the links based on the loggedin user role in MVC

Mar 17 2015 4:32 PM
Hi 
I am using MVC 5, I need to show and hide the links based on the logged in user role.
view code 

if (User.IsInRole("Admin"))
{
<td style="text-decoration:underline">
@Html.ActionLink("Manage Users", "ManageUsers", new { id = Model.id, appname = Model.app_name })
</td>
}
controller code 
[HttpPost]
[Authorize(Roles = "Admin")]
public ActionResult ApplicationEdit()
{
////////////// 

hide the link when I logged in as a normal user, it works perfectly. But when I logged in as Admin it is not showing the link. hide the link both time. my requirement is hide the link only when logged in as a normal user not Admin.
 
 


Answers (1)