@inject NavigationManager Navigation

<p class="m-4 text-muted">Redirigiendo al inicio...</p>

@code {
    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender)
        {
            var relativePath = Navigation.ToBaseRelativePath(Navigation.Uri);
            var targetPath = string.IsNullOrWhiteSpace(relativePath)
                ? "/"
                : $"/{relativePath}";

            var loginUrl = targetPath == "/"
                ? "/"
                : $"/?returnUrl={Uri.EscapeDataString(targetPath)}";

            Navigation.NavigateTo(loginUrl, true);
        }
    }
}
