UserValidatedEventArgs.UserName Property

 
System_CAPS_noteNote

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

Gets the user name of the validated user.

Namespace:   System.Web.ClientServices.Providers
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public string UserName { get; }

Property Value

Type: System.String

The user name of the validated user.

The following example code demonstrates how to use this property to display the user name in the title bar of a form.

private ClientFormsAuthenticationMembershipProvider formsMembershipProvider =
    (ClientFormsAuthenticationMembershipProvider)
    System.Web.Security.Membership.Provider;
private String appName = "ClientAppServicesDemo";

private void AttachUserValidatedEventHandler()
{
    formsMembershipProvider.UserValidated += 
        new EventHandler<UserValidatedEventArgs>(Form1_UserValidated);
}

private void Form1_UserValidated(object sender, UserValidatedEventArgs e)
{
    // Set the form's title bar to the application name and the user name.
    this.Text = String.Format("{0} ({1})", appName, e.UserName);
}

.NET Framework
Available since 3.5
Return to top
Show: