Roles.DeleteCookie メソッド
アセンブリ: System.Web (system.web.dll 内)



DeleteCookie メソッドは、ロール名をキャッシュするために使用する Cookie の内容をクリアします。ロール名のキャッシュの詳細については、CacheRolesInCookie のトピックを参照してください。

ユーザーのログイン時に DeleteCookie メソッドを呼び出して、キャッシュされているすべてのロール名をクリアするコード例を次に示します。ロール管理を有効にする Web.config ファイルの例については、Roles のトピックを参照してください。
<%@ Page Language="VB" %> <%@ Import Namespace="System.Web.Security" %> <script runat="server"> Public Sub Login_OnClick(sender As Object, args As EventArgs) If Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text) Then Roles.DeleteCookie() FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckbox.Checked) Else Msg.Text = "User authentication failed. Please check your username and password and try again." End If End Sub </script> <html> <head> <title>Login</title> </head> <body> <form runat="server"> <h3>Login</h3> <asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR> Username: <asp:Textbox id="UsernameTextbox" runat="server" /><BR> Password: <asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /><BR> <asp:Button id="LoginButton" Text="Login" OnClick="Login_OnClick" runat="server" /> <asp:CheckBox id="NotPublicCheckbox" runat="server" /> Check here if this is <u>not</u> a public computer </form> </body> </html>
<%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Security" %> <script runat="server"> public void Login_OnClick(object sender, EventArgs args) { if (Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text)) { Roles.DeleteCookie(); FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckbox.Checked); } else Msg.Text = "User authentication failed. Please check your username and password and try again."; } </script> <html> <head> <title>Login</title> </head> <body> <form runat="server"> <h3>Login</h3> <asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR> Username: <asp:Textbox id="UsernameTextbox" runat="server" /><BR> Password: <asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /><BR> <asp:Button id="LoginButton" Text="Login" OnClick="Login_OnClick" runat="server" /> <asp:CheckBox id="NotPublicCheckbox" runat="server" /> Check here if this is <u>not</u> a public computer </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Roles.DeleteCookie メソッドのページへのリンク