Skip to main content
.NET Framework 4.5.2+

XafApplication.LastLogonParametersRead Event

Occurs after loading the last logon parameters from the settings storage to the logon object.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<LastLogonParametersReadEventArgs> LastLogonParametersRead

Event Data

The LastLogonParametersRead event's data class is LastLogonParametersReadEventArgs. The following properties provide information specific to this event:

Property Description
LogonObject Provides access to the logon parameters to be displayed in a logon Window.
SettingsStorage Provides access to the settings storage which is used to load logon parameters.

Remarks

A logon Window contains a View which represents a Security System‘s logon parameters. By default, this View shows the last user’s parameters. To load these parameters, a special storage object is created. In a Windows Forms application, it loads logon parameters from the LogonParameters file. In an ASP.NET Web Forms application, it loads them from cookies. When the application is launched for the first time, the logon parameters storage is empty.

You can handle the LastLogonParametersRead event to customize the loaded logon parameters. Use the handler’s LastLogonParametersReadEventArgs.LogonObject parameter to modify the logon parameters loaded from the settings storage. The example below demonstrates how to display the “Guest” user name when the application is launched for the first time.

In the Windows Forms application project’s Program.cs (Program.vb in VB) file:

static void Main() {
    // ...
    winApplication.LastLogonParametersRead += 
        new EventHandler<LastLogonParametersReadEventArgs>(winApplication_LastLogonParametersRead);
    // ...
    winApplication.Setup();
    winApplication.Start();
    // ...
}
static void winApplication_LastLogonParametersRead(
    object sender, LastLogonParametersReadEventArgs e) {
    if(string.IsNullOrEmpty(((AuthenticationStandardLogonParameters)e.LogonObject).UserName)) {
        ((AuthenticationStandardLogonParameters)e.LogonObject).UserName = "Guest";
    }
}

In the ASP.NET Web Forms application project’s Global.asax.cs (Global.asax.vb in VB) file:

protected void Session_Start(object sender, EventArgs e) {
    // ...
    WebApplication.Instance.LastLogonParametersRead += 
        new EventHandler<LastLogonParametersReadEventArgs>(Instance_LastLogonParametersRead);
    // ...
    WebApplication.Instance.Setup();
    WebApplication.Instance.Start();
}
private void Instance_LastLogonParametersRead(
    object sender, LastLogonParametersReadEventArgs e) {
    if(string.IsNullOrEmpty(((AuthenticationStandardLogonParameters)e.LogonObject).UserName)) {
        ((AuthenticationStandardLogonParameters)e.LogonObject).UserName = "Guest";
    }
}

Note

The same task can be accomplished via handling the XafApplication.LastLogonParametersReading and modifying the logon parameters before they are loaded from the settings storage. Additionally, you can handle the XafApplication.LastLogonParametersWriting event to specify the custom logic applied when saving logon parameters to the settings storage.

When using custom logon parameters, you can implement the ICustomObjectSerialize interface. The logon parameters saving and loading can be handled in the ICustomObjectSerialize.ReadPropertyValues and ICustomObjectSerialize.WritePropertyValues methods.

See Also