@inject NavigationManager Navigation

@code {
    protected override void OnInitialized()
    {
        var relativePath = Navigation.ToBaseRelativePath(Navigation.Uri);
        var returnUrl = string.IsNullOrWhiteSpace(relativePath)
            ? "/"
            : relativePath.StartsWith("/", StringComparison.Ordinal) ? relativePath : $"/{relativePath}";

        Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(returnUrl)}");
    }
}
