No one work's, the only one who I managed to works is this:
This is reasonable, if you consider what the method IsInRole
does.
Gets a value indicating whether the currently logged-on user is in the
specified role. The API is only intended to be called within the
context of an ASP.NET request thread, and in that sanctioned use case
it is thread-safe.
That being said a user may has the role of Admin (so UserIsInRole("Admin")
returns true) but may not has the role of User (so UserIsInRole("User")
returns false). So User.IsInRole("Admin") && User.IsInRole("User")
would evaluate to false
.
That you might need is this:
// If the user's role is either admin or user then do something
@if (User.IsInRole("Admin") || User.IsInRole("User"))
{
//my code
}