AnonymousIdentificationEventHandler 委托

定义

表示处理 AnonymousIdentificationModuleAnonymousIdentification_Creating 事件的方法。Represents the method that handles the AnonymousIdentification_Creating event of a AnonymousIdentificationModule.

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

事件源。The source of the event.

继承
AnonymousIdentificationEventHandler

示例

下面的代码示例使用AnonymousIdentification_Creating事件将匿名标识符设置为自定义值。The following code example uses the AnonymousIdentification_Creating event to set the anonymous identifier to a custom value.

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

注解

委托是AnonymousIdentificationModule Creating为类的事件定义的。 AnonymousIdentificationEventHandlerThe AnonymousIdentificationEventHandler delegate is defined for the Creating event of the AnonymousIdentificationModule class. 可以通过在 ASP.NET Creating应用程序的AnonymousIdentificationModule global.asax 文件中指定名为AnonymousIdentification_Creating的子例程来访问类的事件。You can access the Creating event of the AnonymousIdentificationModule class by specifying a subroutine named AnonymousIdentification_Creating in the Global.asax file for your ASP.NET application. Creating 事件PostAuthenticateRequest在事件期间引发。The Creating event is raised during the PostAuthenticateRequest event.

使用当前AnonymousIdentificationModule AnonymousIdentificationEventArgs 构造对象并将其传递给AnonymousIdentification_Creating事件。HttpContextThe AnonymousIdentificationModule constructs an AnonymousIdentificationEventArgs object using the current HttpContext and passes it to the AnonymousIdentification_Creating event.

可以使用提供给AnonymousID AnonymousIdentification_Creating事件的AnonymousIdentificationEventArgs对象的属性, 将匿名标识符设置为自定义值。You can use the AnonymousID property of the AnonymousIdentificationEventArgs object supplied to the AnonymousIdentification_Creating event to set the anonymous identifier to a custom value. 如果未在AnonymousID AnonymousIdentification_Creating事件期间为属性指定值, Guid则使用。If you do not specify a value for the AnonymousID property during the AnonymousIdentification_Creating event, a Guid is used.

仅当匿名身份验证Enabled通过将配置元素设置为true时, 才会引发 AnonymousIdentification_Creating 事件。The AnonymousIdentification_Creating event is only raised when anonymous identification is Enabled by setting the configuration element to true.

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于