XafApplication.LastLogonParametersRead Event
Occurs after loading the last logon parameters from the settings storage to the logon object.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v25.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
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 that displays Security System‘s logon parameters. In a Windows Forms application, this View shows the last user’s parameters. To load these parameters, XAF creates a storage object. It loads logon parameters from the LogonParameters file. When the application is launched for the first time, the logon parameters storage is empty. ASP.NET Core Blazor applications do not create the last user’s parameters storage by default.
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 following code snippet displays the “Guest” user name when the application is launched for the first time.
using DevExpress.ExpressApp;
// ...
namespace MySolution.Module;
public sealed partial class MySolutionModule : ModuleBase {
// ...
public override void Setup(XafApplication application) {
base.Setup(application);
application.LastLogonParametersRead += Application_LastLogonParametersRead;
}
private void Application_LastLogonParametersRead(object sender, LastLogonParametersReadEventArgs e) {
if (e.LogonObject is AuthenticationStandardLogonParameters standardLogonParameters && string.IsNullOrEmpty(standardLogonParameters.UserName)) {
standardLogonParameters.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.