The requested page is not available for the requested platform. You are viewing the content for Default platform.

XafApplication.LastLogonParametersReading Event

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

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

public event EventHandler<LastLogonParametersReadingEventArgs> LastLogonParametersReading
Public Event LastLogonParametersReading As EventHandler(Of LastLogonParametersReadingEventArgs)

Event Data

The LastLogonParametersReading event handler receives an argument of the LastLogonParametersReadingEventArgs type. 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 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 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.

See Also