AnonymousIdentificationModule.Creating 事件

定義

建立新的匿名識別項時發生。

public:
 event System::Web::Security::AnonymousIdentificationEventHandler ^ Creating;
public event System.Web.Security.AnonymousIdentificationEventHandler Creating;
member this.Creating : System.Web.Security.AnonymousIdentificationEventHandler 
Public Custom Event Creating As AnonymousIdentificationEventHandler 

事件類型

範例

下列程式碼範例會使用 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

備註

事件 Creating 會在事件期間 PostAuthenticateRequest 引發。

您可以在 ASP.NET 應用程式的 Global.asax 檔案中指定名為AnonymousIdentification_Creating的副程式,以存取 CreatingAnonymousIdentificationModule 類別的事件。

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

只有在匿名識別為 Enabled 時,才會引發AnonymousIdentification_Creating事件。

適用於