Skip to main content
.NET 6.0+

XafApplication.LastLogonParametersReading Event

Occurs before 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<LastLogonParametersReadingEventArgs> LastLogonParametersReading

Event Data

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

Property Description
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
LogonObject Specifies the object that specifies the logon parameters to be displaed 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 LastLogonParametersReading event to load custom logon parameters. Use the handler’s LastLogonParametersReadingEventArgs.SettingsStorage parameter to load the last logon parameters to the object specified by the LastLogonParametersReadingEventArgs.LogonObject parameter. The example below demonstrates how to set the user name shown when the application is launched for the first time to “Guest”.

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

static void Main() {
    // ...
    winApplication.LastLogonParametersReading += 
        new EventHandler<LastLogonParametersReadingEventArgs>(
            winApplication_LastLogonParametersReading);
    // ...
    winApplication.Setup();
    winApplication.Start();
    // ...
}
static void winApplication_LastLogonParametersReading(
    object sender, LastLogonParametersReadingEventArgs e) {
    if (string.IsNullOrEmpty(e.SettingsStorage.LoadOption("", "UserName"))) {
        e.SettingsStorage.SaveOption("", "UserName", "Guest");
    }
}

In an 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.LastLogonParametersReading += 
        new EventHandler<LastLogonParametersReadingEventArgs>(
            Instance_LastLogonParametersReading);
    // ...
    WebApplication.Instance.Setup();
    WebApplication.Instance.Start();
}
private void Instance_LastLogonParametersReading(
    object sender, LastLogonParametersReadingEventArgs e) {
    if (string.IsNullOrEmpty(e.SettingsStorage.LoadOption("", "UserName"))) {
        e.SettingsStorage.SaveOption("", "UserName", "Guest");
    }
}

Note

The same task can be accomplished by handling the XafApplication.LastLogonParametersRead and modifying the logon parameters which are already 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.

Default parameter loading can be prevented by setting the handler’s Handled parameter to true. When you set this parameter to true and add no other code to the LastLogonParametersReading event handler, the logon parameters shown in the logon window will always be empty. If it is required to implement a custom logic, add the corresponding code to the event handler and set Handled to true, to indicate that it is not required to perform the default process of loading the last logon parameters from the settings storage to the logon object.

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.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the LastLogonParametersReading event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also