RoleManagerModule.GetRoles 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
全域應用程式事件,在 RoleManagerModule 已準備好建立表示目前使用者的 RolePrincipal 時引發。
public:
event System::Web::Security::RoleManagerEventHandler ^ GetRoles;
public event System.Web.Security.RoleManagerEventHandler GetRoles;
member this.GetRoles : System.Web.Security.RoleManagerEventHandler
Public Custom Event GetRoles As RoleManagerEventHandler
事件類型
範例
下列範例顯示 GetRoles 包含在 ASP.NET 應用程式的 Global.asax 檔案中的 事件。 事件 GetRoles 會為在 Web.config 檔案中啟用追蹤的應用程式新增追蹤通知。
public void RoleManager_OnGetRoles(object sender, RoleManagerEventArgs args)
{
args.Context.Trace.Write("Roles", "Applying Role Information");
}
Public Sub RoleManager_OnGetRoles(sender As Object, args As RoleManagerEventArgs)
args.Context.Trace.Write("Roles", "Applying Role Information")
End Sub
備註
事件 GetRoles 會在 建立 RolePrincipal 物件之前 RoleManagerModule 引發,並將它指派給 User 的 CurrentHttpContext 屬性。 您可以使用此事件來稽核何時套用角色資訊,或以您自己的程式碼取代 的 RoleManagerModule 建立 RolePrincipal 。
您可以藉由 RoleManagerModule 在 事件中 GetRoles 將 的 RoleManagerEventArgstrue
屬性設定 RolesPopulated 為 ,以取消角色資訊的套用。
如果您在事件處理常式中 GetRoles 將 設定 RolesPopulated 為 true
,則 User 目前的 HttpContext 屬性不會由 RoleManagerModule 設定為 RolePrincipal 物件。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應