If I am not missing anything that is a VB service, defined under
Microsoft.VisualBasic.ApplicationServices[
^], not an MVC one. However it is indeed executed like this,
User.IsInRole(string)
[
^].
You can consider using the Authorize attribute and pass the role to it,
[Authorize(Roles="Admin")]
public ActionResult YourAction() {
}
This would do the trick for you and would allow admins only to access the content. Note that it is not applied to a content block, but to the action itself. And on a second thought, you may consider asking that framework developers for guidance on using this function in the application. They would have a solution to this problem as why is this function throwing an exception.
Otherwise, you may also use the Roles object and get the result for user,
if(Roles.IsUserInRole("username", "role-name")) {
}
This approach is easy because it can be applied to a content block rather than entire action. Read more about
Roles.IsUserInRole(string, string)
[
^] on MSDN.