asp.net成员 - 如何确定编程是用户在角色 [英] asp.net membership - how to determine programatically is user is in role

查看:160
本文介绍了asp.net成员 - 如何确定编程是用户在角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是code用于确定用户是一个角色?

我已经设置了所有通过ASP.NET配置安全选项卡的用户,但现在想要把逻辑周围的一些关键领域所以只能在某些角色的人可以查看和访问这些区域。


解决方案

 如果(User.IsInRole(角色名称)){
  //我的行动
}

What is the code for determining if a user is in a role?

I have set up all the users through the ASP.NET Configuration Security tab but now want to put logic around some key areas so only people in certain roles can see and access these areas.

解决方案

if (User.IsInRole("rolename")) {
  // my action
}

这篇关于asp.net成员 - 如何确定编程是用户在角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆