You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KWWebInvApp/Shared/RedirectToLogin.razor

35 lines
1.1 KiB
Plaintext

@using KWWebInvApp.Data
@using KWWebInvApp.Services;
@inject NavigationManager navigationManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@code {
protected override async Task OnInitializedAsync()
{
//var returnUrl = Navigation.ToBaseRelativePath(Navigation.Uri);
//if (string.IsNullOrWhiteSpace(returnUrl))
// Navigation.NavigateTo("/userlogin", true);
//else
//{
// if (returnUrl == "userlogin")
// Navigation.NavigateTo("/userlogin", true);
// else
// Navigation.NavigateTo($"/userlogin?returnUrl={returnUrl}", true);
//}
}
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
var returnUrl = navigationManager.ToBaseRelativePath(navigationManager.Uri);
if (string.IsNullOrWhiteSpace(returnUrl))
navigationManager.NavigateTo("/userlogin", true);
else
navigationManager.NavigateTo($"/userlogin?returnUrl={returnUrl}", true);
}
}