如何为单个网页提供安全性 [英] how to provide security to single webpage

查看:97
本文介绍了如何为单个网页提供安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实要求在所有这些aspx页面中,我需要为所有这些页面提供对用户和管理员的访问权限,但是对于单个网页,我需要只提供对存在于其中的管理员的访问权限数据库,我该如何解决?

i do have requirement that among all bunch of aspx pages, i need to provide access on all of those pages to both users and admins, but for a single webpage i need to provide access to only administrators who are present in database, how can i solve this?

推荐答案

有几种方法可以阻止用户访问页面

1.检查用户角色页面的Page_Load事件,如果有效的用户角色然后服务页面,则另外明智地重定向到另一个页面。

2.预防通过XML Xpath逻辑显示菜单链接。

3.将页面放在一个文件夹中并使用表单身份验证。
There are several ways to prevent a page to users
1. Check the User role in Page_Load event of the page, If valid user role then serve the page other wise redirect to another page.
2.Prevent to display the menu link through XML Xpath logic.
3.Put the page in one folder and use forms authentication.


为此有很多方法: -



第一个是这样的:你可以在登录表中给出角色列表示角色。

和商店角色是会话[角色]。

在这些页面上给出两个条件这只适用于管理员。

条件是页面加载。



if(Session [Id] ==abcd&& session [Role] ==admin)

{

do什么你想要的

}

其他

东西.....



第二种方法:如果他们只是单一的Admin。然后你可以把他们的id硬编码在页面加载在这个页面上,这只是为了管理员



if(Session [Id] ==AD1234)

{

}



和许多方法来解决这个问题。你可以试试......
For this there are many approach :-

First one is that : you can give Role Column in your login Table Which shows the role.
And Store Role is session["Role"].
Give Two conditions on those page which is only for administrator.
Condition is on Page Load.

if(Session["Id"] == "abcd" && session["Role"] == "admin")
{
do what ever you want
}
else
something.....

Second Approach : If their is only single Admin. Then you can put their id hard coded in Page load on this page which is only for admin

if(Session["Id"] == "AD1234" )
{
}

and many approaches to solve this problem. You can try ...


这篇关于如何为单个网页提供安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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