如何在内部页面中为不同用户显示或隐藏内容 [英] how to show or hide something in inner page for different users

查看:74
本文介绍了如何在内部页面中为不同用户显示或隐藏内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我使用带有C#的Asp.net创建一个Web应用程序.
那是使用一种登录表单,但是像admin,student这样的不同用户

如果是admin,则登录后意味着我需要在下一页显示所有控件.

如果学生已登录,则意味着我需要在下一页中隐藏一些链接和控件..

这是下一页的母版页.

我该如何解决此问题,请帮助我...

Hi..

Me creating a web application using Asp.net with C#..

in that am using one login form but different users like admin,student

if admin ,logged in means i need to show all the controls in next page.

if student logged in means i need to hide few links and controls in next page..

here the next page is a Master Page..

How can i solve this problem Please Help me...

推荐答案

根据您的问题..您正在谈论根据用户的角色授予用户权限. br/>
Raajendran,您的问题有几种可能.最简单的方法是为用户roles 管理session ,并根据角色显示和隐藏Masterpage中的控件.

例如:

According to your question.. you are talking about giving rights to the user according to their roles.

Raajendran, There are several possiblities for your question. Most simple is to manage a session for your user roles and according to the roles show and hide the controls in your Masterpage.

for example:

if(loginid="admin")
{
session["userrole"]="Admin"
}
else if(loginid="Student")
{
 session["userrole"]="student"
}



然后在您的母版页中检查登录用户是admin还是学生,并显示或隐藏您的链接.


谢谢
Ashish

如果得到答案,则使其成为解决方案,以便其他人也可以参考该解决方案..



Then in your Master page check whether the login user is admin or student and show or hide your links.


Thanks
Ashish

Make it solution if you got your answer, so other can refer to the solution too..


您是否在这里谈论Role based security?如果是,这是一个巨大的话题.暂时,您只需要检查默认页面Page_Load上的角色,将角色存储在会话中或某种状态管理技术中,然后在每个页面上进行检查即可.根据这些值,您可以启用或禁用页面中的控件.但是,这是一种非常模糊或肮脏的方法.您将需要了解Role Based Security 及其在.Net Web应用程序中的实现.以下文章将帮助您理解:
具有表单身份验证的基于角色的安全性 [ http://www.4guysfromrolla.com/webtech/121901-1.shtml [ ^ ]
自定义成员身份,角色提供者,网站管理工具以及对单个文件的基于角色的访问 [ ^ ]
Are you talking about Role based security here? If yes it is a huge topic. For time being what you can do is just check the role on the Page_Load of default page, store the role in a session or some state management technique and check the same on every page. Based on the values you enable or disable the controls in your pages. However this is a very vague or dirty way of doing it. You will need to understand about Role Based Security and it implementation in .Net Web Applications. Below articles will help you in understanding:
Role-based Security with Forms Authentication[^]
http://www.4guysfromrolla.com/webtech/121901-1.shtml[^]
Custom Membership, Role Providers, Website administration tool, and Role based access to individual files[^]



就像我的朋友ashish所说的那样,您可以在会话中存储用户的角色并检查会话中的特权.
但是在asp.net中有一种简单的方法基于角色的授权"来完成此任务.按照以下波纹管链接:
http://msdn.microsoft.com/en-us/library/wce3kxhd.aspx [ ^ ]
ASP.NET身份验证和授权 [ ASP.NET中的表单身份验证和授权 [ ^ ]

这可能对您有帮助.
祝一切顺利.
--Amit
Hi,
Like my friend ashish said, you can store user''s role in your session and check the session for privileges.
But there is a simple way "Role based authorization" in asp.net to do this task. follow the links bellow:
http://msdn.microsoft.com/en-us/library/wce3kxhd.aspx[^]
ASP.NET authentication and authorization[^]
Form authentication and authorization in ASP.NET[^]

This may help you.
All the best.
--Amit


这篇关于如何在内部页面中为不同用户显示或隐藏内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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