Marius Vasile

Marius Vasile

  • 602
  • 1.7k
  • 124.4k

asp.net core razor use of role in view

Dec 4 2020 4:23 AM
I want to be able to give users access to view sections of the View and I can do that with
 
  1. @if (Model.UserDataRole.RoleName == "Issuer")  
  2.     {  
  3.         //some divs here  
  4.     }  
and if 
  1. @if (Model.UserDataRole.RoleName == "Admin")  
  2.     {  
  3.         //other divs here  
  4.     }  
 My questions, is it safe to do so or I should try to do it in the cshtml.cs instead?

Answers (6)