RolePrincipal.CachedListChanged Property
Gets a value indicating whether the list of role names cached with the RolePrincipal object has been modified.
Assembly: System.Web (in System.Web.dll)
Property Value
Type: System.Booleantrue if the list of role names cached with the RolePrincipal object has been modified; otherwise, false.
The CachedListChanged property will return true after role names have been retrieved from the default role Provider and added to the cache by the GetRoles method, or when the IsInRole method calls the IsUserInRole method of the default role provider and then receives a response of true, resulting in the role name passed to the IsInRole method being added to the cache.
The CachedListChanged property will also return true if CookieSlidingExpiration is set to true and the ExpireDate has passed, resulting in a new ExpireDate being set.
The following example displays role-caching information for the current user if role management is enabled. For information on enabling role management, see the Roles class.
<%@ 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>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.