SelectingProviderEventArgs Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Provides data for the SelectingProvider event.

Namespace:   System.Web.ApplicationServices
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)


Public Class SelectingProviderEventArgs
	Inherits EventArgs


Gets or sets the role provider to use for retrieving the user's roles.


Gets the authenticated user.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

The SelectingProviderEventArgs class supplies values to the SelectingProvider event handler. You create a SelectingProvider event handler to select the role provider at run time.

The RoleService class raises the SelectingProvider event when either the IsCurrentUserInRole method or the GetRolesForCurrentUser method of the RoleService class is called.

You use the User property to retrieve information about the logged-in user. To retrieve role information through a non-default role provider, set the ProviderName property to the name of the role provider that you want the RoleService object to use.

The following example shows an event handler for the SelectingProvider event. The event handler uses the SelectingProviderEventArgs object to check the user name and to set the role provider to use. The event handler is bound to the SelectingProvider event in the Application_Start method of the Global.asax file.

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    AddHandler System.Web.ApplicationServices.RoleService.SelectingProvider, _
        AddressOf Me.RoleService_SelectingProvider
End Sub

Sub RoleService_SelectingProvider _
(ByVal sender As Object, _
 ByVal e As System.Web.ApplicationServices.SelectingProviderEventArgs)

    If (e.User.Identity.Name.IndexOf("") > 0) Then
        e.ProviderName = "EmployeeRoleProvider"
        e.ProviderName = "CustomerRoleProvider"
    End If
End Sub

.NET Framework
Available since 3.5

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top