在ASP.NET 2.0 中认证方式设置为form
但在角色里只能设置该角色相对于目录的访问权限
因为我的程序每一页就是一个功能模块,所以我要精确到某角色能否访问哪一页,又不想每一页都建一个目录,能否实现呢?谢谢

解决方案 »

  1.   

    jimu8130(IBMT43) 说的对啊。
    类似这样:
    public class BasePage : Page
    {
    #region override members [Permission(Const.System_AllowVisitPage), PrincipalPermission(SecurityAction.Demand, Role=PermissionAttribute.PermissionRole)]
    protected override void OnLoad(EventArgs e) {
    base.OnLoad (e);
    checkAuth();
     

    }
    。。protected virtual void checkAuth(string permissionNO)
    {
    IAOPResult Result=Securitor.Authorize(permissionNO,string.Empty,false);
     
    if(Result.IsFailed)
    {  
    Response.Write("<script>alert('没有授权!')</script>");
    Response.End();
    }
    }
      

  2.   

    if you don't have many pages, look into location tagHOW TO: Control Authorization Permissions in an ASP.NET Application
    http://support.microsoft.com/kb/316871otherwise, consider to use an xml to specify the mapping between roles and pages, and write your own authorization HttpModule or verify it in, for example, Application_AuthorizeRequest