-2

I want to give access to System Administrator and Administrator but when I am writing @if (User.IsInRole("System Administrator","Administrator")) getting error(no overload for method'IsINRole' take 2 arguments)allthough on controller it is working

[CustomAuthorize(Roles = "System Administrator,Administrator")] public class CategoriesController : Controller

I there other a way to solve this problem?

Megha Misra
  • 35
  • 1
  • 7

1 Answers1

2

You can't pass multiple roles to the IsInRole function. But you can use the || functionality in c# as below.

@if (User.IsInRole("System Administrator") || User.IsInRole("Administrator"))
{
    //your code here
}
ViVi
  • 4,339
  • 8
  • 29
  • 52