如何在c#中为用户分配角色 [英] How to assign roles to users in c#

查看:132
本文介绍了如何在c#中为用户分配角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai朋友,



我有一个疑问。目前我正在c#web应用程序中开发事件跟踪器应用程序。如果用户在应用程序中注册,那么他们只能访问特定页面。不是所有页面。我怎么能这样做。我无法为管理员用户创建一个新的单独页面.Plz帮助我。





提前致谢。

Hai friends,

I have one doubt.Presently i am developing the Incident tracker application in c# web application.If a user is registered in the application then they can able to access specific pages only.Not all the pages.How can I do this.I can't create a new seperate page for the admin users.Plz help me.


Thanks in advance.

推荐答案

您可以拥有数据库驱动的角色基本访问权限。您只需存储所有用户信息和相应的可访问页面。每当用户尝试访问某个页面时,只需检查数据库是否该用户有权访问该页面。
You can have database driven role base access. You just store all the users information and corresponding accessible pages. Whenever user try to access some page, just check database whether that user has access to that page or not.


您可以创建角色主表来定义系统中的所有角色。 />
对于每个角色设置角色用户应该查看的页面URL



当用户在门户网站上注册时,为他分配角色。当他/她登录门户网站时检查角色并根据角色隐藏并显示菜单。
you can create a role master table define all the roles in the system.
For every role set the pages URL which should the user of a role can view

When a user registers on the portal assign him the role . When he/she logs in the portal check for the roles and according to roles hide and show the menues.


使用角色提供者!

Understanding-ASP-NET-Roles-and-Membership-A-Begin

您可以实现自己的角色提供者来为用户指定角色!

Google搜索

自定义角色提供商

实施角色提供者
use role provider!
Understanding-ASP-NET-Roles-and-Membership-A-Begin
You can implement your own role provider to give user specified roles!
Googled
Custom Role Providers
Implementing a Role Provider


这篇关于如何在c#中为用户分配角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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