RolePrincipal.IsRoleListCached 속성

정의

사용자에 대한 역할 목록이 쿠키에 캐시되었는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsRoleListCached { bool get(); };
public bool IsRoleListCached { get; }
member this.IsRoleListCached : bool
Public ReadOnly Property IsRoleListCached As Boolean

속성 값

Boolean

역할 이름이 쿠키에 캐시되었으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 역할 관리를 사용하는 경우 현재 사용자에 대한 역할 캐싱 정보를 표시합니다. 역할 관리를 사용하도록 설정하는 방법에 대한 자세한 내용은 클래스를 참조하세요 Roles .

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

public void Page_Load()
{

  try
  {
    RolePrincipal r = (RolePrincipal)User;

    IsCachedLabel.Text     = r.IsRoleListCached.ToString();
    CacheChangedLabel.Text = r.CachedListChanged.ToString();
    ExpiredLabel.Text      = r.Expired.ToString();
    VersionLabel.Text      = r.Version.ToString();
    IssueDateLabel.Text    = r.IssueDate.ToString();
    ExpireDateLabel.Text   = r.ExpireDate.ToString();
    CookiePathLabel.Text   = r.CookiePath;

    Msg.Text = "";
  }
  catch (InvalidCastException)
  {
    Msg.Text = "User is not of type RolePrincipal. Are roles enabled?";
  }

}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Role Information</title>
</head>
<body>

<form id="form1" runat="server">

  Role Information for <b><%=User.Identity.Name%></b>.<br />

  <asp:Label id="Msg" runat="Server" ForeColor="maroon" /><br />

  <table border="1" cellpadding="4" cellspacing="4">
    <tr>
      <td>IsRoleListCached</td>
      <td><asp:Label id="IsCachedLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>CachedListChanged</td>  
      <td><asp:Label id="CacheChangedLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>Expired</td>
      <td><asp:Label id="ExpiredLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>Version</td>
      <td><asp:Label id="VersionLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>IssueDate</td>
      <td><asp:Label id="IssueDateLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>ExpireDate</td>
      <td><asp:Label id="ExpireDateLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>CookiePath</td>
      <td><asp:Label id="CookiePathLabel" runat="Server" /></td>
    </tr>
  </table>

</form>


</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

Public Sub Page_Load()

    Try
    Dim r As RolePrincipal = CType(User, RolePrincipal)

    IsCachedLabel.Text     = r.IsRoleListCached.ToString()
    CacheChangedLabel.Text = r.CachedListChanged.ToString()
    ExpiredLabel.Text      = r.Expired.ToString()
    VersionLabel.Text      = r.Version.ToString()
    IssueDateLabel.Text    = r.IssueDate.ToString()
    ExpireDateLabel.Text   = r.ExpireDate.ToString()
    CookiePathLabel.Text   = r.CookiePath

    Msg.Text = ""
  Catch e As InvalidCastException
    Msg.Text = "User is not of type RolePrincipal. Are roles enabled?"
  End Try

End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Role Information</title>
</head>
<body>

<form id="form1" runat="server">

  Role Information for <b><%=User.Identity.Name%></b>.<br />

  <asp:Label id="Msg" runat="Server" ForeColor="maroon" /><br />

  <table border="1" cellpadding="4" cellspacing="4">
    <tr>
      <td>IsRoleListCached</td>
      <td><asp:Label id="IsCachedLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>CachedListChanged</td>  
      <td><asp:Label id="CacheChangedLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>Expired</td>
      <td><asp:Label id="ExpiredLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>Version</td>
      <td><asp:Label id="VersionLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>IssueDate</td>
      <td><asp:Label id="IssueDateLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>ExpireDate</td>
      <td><asp:Label id="ExpireDateLabel" runat="Server" /></td>
    </tr>
    <tr>
      <td>CookiePath</td>
      <td><asp:Label id="CookiePathLabel" runat="Server" /></td>
    </tr>
  </table>

</form>


</body>
</html>

설명

경우는 cacheRolesInCookie 로 설정 되어 애플리케이션 Web.config 파일에서 특성 true, 특정 역할에 사용자 멤버 자격을 선택 하면 현재 사용자에 대 한 역할 이름의 목록이 쿠키에 기록 됨. 이 속성은 IsRoleListCached 역할 이름이 쿠키에 기록되었는지 여부를 나타냅니다. 구성 특성이 cacheRolesInCookie 될 수 있지만 역할 정보가 쿠키에 IsRoleListCached 기록될 true때까지 속성이 반환 true 되지 않습니다. 사용자 IsRoleListCached 에 대한 역할 검사가 수행되지 않으면 반환 false됩니다.

적용 대상

추가 정보