Asp.net中的成员资格和角色 [英] Membership and Roles in Asp.net

查看:73
本文介绍了Asp.net中的成员资格和角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的网站中有2个角色:管理员和用户.我的网站上有一个功能,我希望只允许登录用户执行搜索操作.那么我该怎么做?

在此先谢谢您.

Hi all ,

I have 2 roles in my web: admin and user.And i have a functionality on my web that i want to allow only logged in user to do which is searching for example.So how can i do this ?

Thanks in advance.

推荐答案

一种实现此目的的方法是在代码中实现一个"if"语句,以根据用户的需要显示或隐藏适当的控件.的角色.如果您想了解如何自己实现角色,则应查看以下文章之一:
表单身份验证和基于角色的授权:更快,更简单和正确的方法 [ ^ ]
通过ASP.NET中的角色对用户进行身份验证 [
One way to do this is to implement an "if" statement in your code behind to show or hide the appropriate controls based on the user''s role. If you are looking to understand how to implement the roles themselves, you should check out one of these articles:
Forms Authentication and Role based Authorization: A Quicker, Simpler, and Correct Approach[^]
Authenticate User by Roles in ASP.NET[^].
There are many other articles here on code project that cover this and it would a good idea to start there.


http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx [ http://programming4.us/security/1264.aspx [ http://programming4.us/security/1256.aspx [
http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx[^]
http://programming4.us/security/1264.aspx[^]
http://programming4.us/security/1256.aspx[^]


这篇关于Asp.net中的成员资格和角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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