请详细解释一下(CType(User,RolePrincipal)).GetRoles()起什么作用?
请详细解释一下(CType(User,RolePrincipal)).GetRoles()起什么作用?请分别讲一下,Ctype,User,RolePrincipal,GetRoles分别起什么作用?多谢!
------解决方案--------------------1。 
 在 .aspx.cs 中 ?   
 2。 
 CType(User,RolePrincipal)   
 表示将 this.Page.User (原型为 IPrincipal 接口)属性 强制转换为  RolePrincipal 类型   
 User 表示发出页请求的用户的 IPrincipal。    
 RolePrincipal 表示当前 HTTP 请求的安全信息,包括角色成员资格。   
 3。 
 RolePrincipa rp = CType(User,RolePrincipal); 
 rp.GetRoles();   
 获取 RolePrincipal 是其成员的角色的列表 
 说明: 
 如果 CacheRolesInCookie 是 true,且已经为由 RolePrincipal 表示的用户缓存了角色名称,则 GetRoles 方法将返回缓存中用户是其成员的角色名称的列表。如果未缓存角色名称,则 GetRoles 方法从默认的角色 Provider 中返回用户是其成员的角色名称的列表。只返回当前 ApplicationName 的角色名称。要确定是否已在 RolePrincipal 对象中缓存了角色名称,请检查 IsRoleListCached 属性。   
 4。 
 需要详细信息请看考  
 MSDN: 
 Page.User 属性 http://msdn2.microsoft.com/zh-cn/library/system.web.ui.page.user(VS.80).aspx   
 RolePrincipal 类 http://msdn2.microsoft.com/zh-cn/library/system.web.security.roleprincipal(VS.80).aspx   
 5。 
 不要一个劲的就像要答案,这是很基础很基础的东东了,初学者就要静心先看看书再来, 
 其实我的沙发贴都告诉你答案了,你还在这里等....     
 Good Luck!