Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法配置 aspx/ascx 页面的一部分,比如根据角色将页面中的控件限制为用户,比如可以配置的部分级别访问?因此,如果下一次角色被赋予额外的访问权限来查看以前无法访问的部分,我们可以只配置角色而不是更改代码。这个可以配置吗??提前致谢
您可以通过代码:
Panel.Visible = Roles.IsUserInRole(..);
或者
Panel.Visible = this.User.Identity.IsInRole("..");
然后,当您将它们添加到角色时,面板变得可见。没有任何内置功能可以将控件绑定到角色,然后更改其可见性。但是,通过代码很容易做到。