0

我有自定义SiteMapProvider和RoleProvider一起正常工作:IsAccessibleToUser回报false如果当前用户的角色不SiteMapNode.Roles的请求的页面提及。是否有可能使用打开阻止页面securityTrimmingEnabled =真

所以面包屑或菜单不显示的项目。

但用户仍然可以现在键入URL显示直接打开一个网页。我怎样才能阻止这种行为?

我也有未来的Web.config设置:

<authorization> 
    <allow roles="Admin,Manager,Client" /> 
    <deny users="*" /> 
</authorization> 

回答

0
public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node) 
{ 
    var roles = node.Roles.OfType<string>(); 
    if (roles.Contains("*") || (roles.Count(r => context.User.IsInRole(r)) > 0)) 
    { 
     return true; 
    } 
    else 
    { 
     throw new InsufficientRightsException(); 
    } 
} 
相关问题