I am programming an WebApp with MVC5 and I will check if a User is in a specified Role.
Therefore I have tried to use User.IsInRole("Role")
but it throws an Exception.
I have tried with importing AspNet.Identity and using the User Manager but it can not find the method IsInRoleAsync(userId, role)
:
@using Microsoft.AspNet;
@if(UserManager.IsInRoleAsync(user.Id, "Role")){
// some code
}
Please notice that I use it in a cshtml file and razor syntax. I hope you can help me.
Thank you in advance