How can I create a view that has different displays according to the role the user is in?

后端 未结 8 1372
南方客
南方客 2020-12-04 11:22

I want to create a view that has different displays according to the role the user is in.

Should I create a different view for different roles or should I check the

8条回答
  •  [愿得一人]
    2020-12-04 12:28

    I have base model which from all others models extend. In this model i have loaded the user's roles. Its based on httpcontext.user.isinrole() method. All views are strong typed expecting the base model type. So i can always check in all views something like Model.CurrentUser.IsInRoles(Role1 | Role2). Not only in views of course, but in hole application.

提交回复
热议问题