AnonymousIdentificationEventHandler 代理人

定義

代表處理 AnonymousIdentificationModuleAnonymousIdentification_Creating 事件的方法。

public delegate void AnonymousIdentificationEventHandler(System::Object ^ sender, AnonymousIdentificationEventArgs ^ e);
public delegate void AnonymousIdentificationEventHandler(object sender, AnonymousIdentificationEventArgs e);
type AnonymousIdentificationEventHandler = delegate of obj * AnonymousIdentificationEventArgs -> unit
Public Delegate Sub AnonymousIdentificationEventHandler(sender As Object, e As AnonymousIdentificationEventArgs)

參數

sender
Object

事件的來源。

範例

下列程式碼範例會使用 AnonymousIdentification_Creating 事件,將匿名識別碼設定為自訂值。

public void AnonymousIdentification_Creating(object sender, 
                                             AnonymousIdentificationEventArgs args)
{
  args.AnonymousID = Samples.AspNet.Security.MyIdClass.GetAnonymousId();
  Samples.AspNet.Security.MyIdClass.LogAnonymousId(args.AnonymousID);
}
Public Sub AnonymousIdentification_Creating(sender As Object,  _
                                            args As AnonymousIdentificationEventArgs)
  args.AnonymousID = Samples.AspNet.Security.MyIdClass.GetAnonymousId()
  Samples.AspNet.Security.MyIdClass.LogAnonymousId(args.AnonymousId)
End Sub

備註

委派 AnonymousIdentificationEventHandler 是針對 Creating 類別的事件 AnonymousIdentificationModule 所定義。 您可以在 ASP.NET 應用程式的 Global.asax 檔案中指定名為AnonymousIdentification_Creating的副程式,以存取 CreatingAnonymousIdentificationModule 類別的事件。 事件 Creating 會在 事件期間 PostAuthenticateRequest 引發。

AnonymousIdentificationModule 使用目前的 HttpContext 建構 AnonymousIdentificationEventArgs 物件,並將它傳遞至AnonymousIdentification_Creating事件。

您可以使用 AnonymousID 提供給AnonymousIdentification_Creating事件的 物件屬性 AnonymousIdentificationEventArgs ,將匿名識別碼設定為自訂值。 如果您在AnonymousIdentification_Creating事件期間未指定 屬性的值 AnonymousIDGuid 則會使用 。

只有當匿名識別是 Enabled 將 anonymousIdentification > 組態專案設定 < 為 true 時,才會引發AnonymousIdentification_Creating事件。

擴充方法

GetMethodInfo(Delegate)

取得表示特定委派所代表之方法的物件。

適用於