如何限制普通用户访问特定页面 [英] How to restrict normal user to access particular pages
本文介绍了如何限制普通用户访问特定页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个网站
它有两个角色admin和用户
如果用户登录网站,我想限制一些页面,
如果管理员登录没有限制
从注册表中识别管理员,名称为
i am developing a website
it has two roles admin and user
if user login into the website , i want restrict some pages,
if admin login no restrictions
am identifying admin from registration table with name
推荐答案
你所要做的就是检查登录用户是否属于角色名称。
假设你有两个角色admin和user
All you have to do is check if the logged-in user belong to the role name.
Am assuming you have two roles as "admin" and "user"
Protected Page_Load()
If My.User.IsAuthenticated Then
If Not My.User.IsInRole("admin") Then
Response.Redirect("~/")
End If
End If
End Sub
试用并添加反馈
Try it out and add a feedback
这篇关于如何限制普通用户访问特定页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文