asp.net成员身份-如何以编程方式确定用户是否在角色中 [英] asp.net membership - how to determine programmatically is user is in role

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

问题描述

确定用户是否在角色中的代码是什么?

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

我已经通过"ASP.NET配置安全性"选项卡设置了所有用户,但现在希望在一些关键区域周围添加逻辑,以便只有具有特定角色的人员才能看到和访问这些区域.

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天全站免登陆