Chantry
Chantry

Reputation: 3

Allowing access to multiple Roles Using User.IsInRole

@if (User.IsInRole("Admin")) {
//Link goes here.
}

That all works fine and dandy but what do I do when I would like to allow multiply roles such as:

@if (User.IsInRole("Admin, SuperUser")) {
//Link goes here.
}

Upvotes: 0

Views: 2354

Answers (1)

MadDev
MadDev

Reputation: 1150

You should use the conditional-OR operator (||). See Microsoft documentation here: https://msdn.microsoft.com/en-us/library/6373h346.aspx

@if (User.IsInRole("Admin") || User.IsInRole("SuperUser") {
//Link goes here.
}

Upvotes: 3

Related Questions