Share via


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 引发。

可以通过在 Creating Global.asax 文件中为 ASP.NET 应用程序指定名为 AnonymousIdentification_Creating 的子例程来访问 类的事件AnonymousIdentificationModule

可以使用AnonymousID提供给 AnonymousIdentification_Creating 事件的 对象的 属性AnonymousIdentificationEventArgs将匿名标识符设置为自定义值。 如果在 AnonymousIdentification_Creating 事件期间未为 AnonymousID 属性指定值,Guid则使用 。

仅当匿名标识为 Enabled时,才会引发 AnonymousIdentification_Creating 事件。

适用于