Let's say I have a controller action that is restricted to only certain users, like this:
[Authorize(Roles="somerole")]<br />
public ActionResult TestRestricted() {
return View();
}
On a view, that is public to everyone I have a link to the action defined above:
<%= Html.ActionLink("Click here!", "TestRestricted") %>
What I'd like to do is hide the link for everyone that is not allowed perform the "TestRestricted"-action. Is there a way to check if the current user is authorized to use the corresponding action? Without defining any additional or duplicate access rules in addition to the authorization filter?