如何为不同类型的用户创建不同的视图? [英] How Do I Create Different Views For Different Types Of Users?

查看:112
本文介绍了如何为不同类型的用户创建不同的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三种不同类型的用户,所以我希望隐藏一些字段/标签,具体取决于用户登录。谢谢

i have three different types of users, so i want some fields/ labels to be hidden depending on the user logging in. thanks

推荐答案

请参阅我的评论问题 - 我在你的帖子中看不到很多意义。



但是,让我们推测一下。如果您已经拥有不同类型的用户,那么您的网站上肯定有身份验证。如果您已经拥有身份验证,那么您当然可以在站点(数据库或任何其他数据源)上拥有所有用户和用户配置文件的一些数据,否则您将无法进行身份验证。如果您确实拥有此类用户配置文件数据,则始终可以添加一些数据项,将用户分为三个或任意数量的类。



然后,如果您全部执行此操作,则在身份验证时,您将拥有已经过身份验证的用户的配置文件,从而获得用户类。身份验证机制为您提供有关每个页面的当前用户的信息。甚至用户的类别也不是你必须发明的东西;他们通常被称为角色。请参阅: http://www.asp.net/web-forms / tutorials / security / roles / role-based-authorization-cs [ ^ ]。



现在,拥有所有这些,你可以记住ASP.NET与其他服务器端技术一样,您可以动态生成任何内容类型的任何内容(可能是W3标准采用的内容类型之一)。任何内容都取决于某些条件。其中一个条件是当前用户的角色(类)。等等...



-SA
Please see my comment to the question — I cannot see a whole lot of sense in your post.

However, let's speculate a bit. If you already have "different types of users", you certainly have authentication on your site. If you already have authentication, you certainly have some data with all your users and user profiles on the site (database or any other data source), otherwise you would not have anything to authenticate against. If you do have such user profile data, you can always add some data item classifying the users into three or any number of classes.

Then, if you do it all, at the moment of authentication you have the profile of the user who has authenticated and hence the user class. And authentication mechanism gives you the information on the current user for each page. And even the classes of the users is not something that you have to invent; they are usually called "roles". Please see: http://www.asp.net/web-forms/tutorials/security/roles/role-based-authorization-cs[^].

Now, having all that, you can remember that ASP.NET, like other server-side technologies, allows you to generate any content of any content type (presumable one of the content type adopted by W3 standards) on the fly. Any piece of content can depend on some conditions. One of such conditions would be the role (class) of the current user. And so on…

—SA


这篇关于如何为不同类型的用户创建不同的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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