Role-Based Content asp.net mvc

后端 未结 4 521
-上瘾入骨i
-上瘾入骨i 2020-12-29 00:21

I wish to display content depending on the given role(s) of the active user , in the ASP.NET MVC.

Compare the old fashion way, using WebForms:

protec         


        
4条回答
  •  半阙折子戏
    2020-12-29 00:56

    No you would be placing it in the view file, like so actually:

    <% If (User.IsInRole("Administrator")) { %>
    
    Admin text
    <% } %>

提交回复
热议问题