Using 10.0.0.1613 according to Delphi.
I have trouble with the OnLoginNeeded in my Blazor app.
Session could not be found is triggered but should not be happening in LoginNeeded
I am a Delphi programmer making his first Blazor app.
So maybe I am doing this completely wrong. In that case, maybe a Blazor programmer can give me some hints.
After a week of testing a trying multiple things I am not going to solve this on my own.
Blazor works with DI and a async event-driven model so I might just no work in such a scenario.
These are my Debug lines, so you can see what I mean:
This line “load De server meldt: Session {3EB6E318-D1B2-4894-B780-97BA8D779625} could not be found” should not be happening.
await StamClient.LoadAsync(EnumStamtabellen.st_Kostendragers)
OnLoginNeeded triggered
// Create new session
load De server meldt: Session {3EB6E318-D1B2-4894-B780-97BA8D779625} could not be found
LoginRetry
private async Task Ophalen()
{
try
{
Console.WriteLine("await StamClient.LoadAsync(EnumStamtabellen.st_Kostendragers) ");
var raw = await StamClient.LoadAsync(EnumStamtabellen.st_Kostendragers);
Console.WriteLine("After await StamClient.LoadAsync(EnumStamtabellen.st_Kostendragers) ");
}
catch (Exception ex)
{
Console.WriteLine("load " + ex.Message);
}
}
namespace MyBlazorInteractiveServerApp.Services.RemObjects
{
public class RemObjectsConnection
{
public WinInetHttpClientChannel Channel { get; }
public readonly BinMessage Message;
private readonly AppState _appState;
public RemObjectsConnection(string baseUrl, AppState appState)
{
Message = new BinMessage();
Message.ServerExceptionPrefix = "De server meldt: ";
_appState = appState;
Channel = new WinInetHttpClientChannel { TargetUrl = baseUrl };
Channel.OnLoginNeeded += async (sender, args) =>
{
Console.WriteLine("🔄 OnLoginNeeded triggered");
var username = _appState.Username;
var password = _appState.Password;
if (!string.IsNullOrEmpty(username))
{
try
{
var proxy = new AlgemeenService_AsyncProxy(Message, Channel);
Console.WriteLine("// Create new session");
await proxy.SetSysInlognaamAsync(username);
args.Retry = true;
args.LoginSuccessful = true;
Console.WriteLine("✅ LoginRetry");
}
catch (Exception ex)
{
Console.WriteLine($"❌ LoginRetry failed: {ex.Message}");
args.Retry = false;
}
}
else
{
args.Retry = false;
}
};
}
}
}