❔ NavigationManager: TaskCancelledException

I've got an OAuth login button:
@inject IOptionsMonitor<BaasOptions> Options;
@inject NavigationManager Navigation;

<MudButton OnClick="OnClickLogin" Variant="Variant.Text" Color="Color.Inherit">Login</MudButton>

@code {
[CascadingParameter(Name = "HttpRequestState")]
protected HttpRequestState? HttpRequestState { get; set; }

public void OnClickLogin()
{
ArgumentNullException.ThrowIfNull(HttpRequestState);

string currentPage = Navigation.ToBaseRelativePath(Navigation.Uri);
string redirect = HttpRequestState.HostUri + $"/OAuthCallback?{Constants.QueryParams.OriginalPage}={currentPage}";

QueryBuilder qb =
new()
{
// some query params for the request, omitted for brevity
};

Navigation.NavigateTo(new Uri(this.Options.CurrentValue.BaasUrlParsed, "/custom/thirdparty/auth") + qb.ToString());
}
}
@inject IOptionsMonitor<BaasOptions> Options;
@inject NavigationManager Navigation;

<MudButton OnClick="OnClickLogin" Variant="Variant.Text" Color="Color.Inherit">Login</MudButton>

@code {
[CascadingParameter(Name = "HttpRequestState")]
protected HttpRequestState? HttpRequestState { get; set; }

public void OnClickLogin()
{
ArgumentNullException.ThrowIfNull(HttpRequestState);

string currentPage = Navigation.ToBaseRelativePath(Navigation.Uri);
string redirect = HttpRequestState.HostUri + $"/OAuthCallback?{Constants.QueryParams.OriginalPage}={currentPage}";

QueryBuilder qb =
new()
{
// some query params for the request, omitted for brevity
};

Navigation.NavigateTo(new Uri(this.Options.CurrentValue.BaasUrlParsed, "/custom/thirdparty/auth") + qb.ToString());
}
}
And it seems I get quite a few errors from the deployment: Navigation failed when changing the location to https://baas.lukefz.xyz/custom/thirdparty/auth[...] with an inner exception of
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass13_0.<<NavigateToCore>g__PerformNavigationAsync|0>d.MoveNext()
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass13_0.<<NavigateToCore>g__PerformNavigationAsync|0>d.MoveNext()
I found a github issue with something similar which I now can't find again, but the root cause there was using Task.Result. However I am not using that anywhere so I'm not sure what is happening here, any suggestions would be appreciated
8 Replies
dreadfullydistinct
dreadfullydistinctOP14mo ago
To add to the above -- I haven't noticed anything actually wrong with the navigation and the button works totally fine. But I'm wondering if there's an actual cause to be fixed here or if I should just catch this exception and ignore it
Vigil Light
Vigil Light14mo ago
Hi Are you working with ASP net?
dreadfullydistinct
dreadfullydistinctOP14mo ago
Yeah
Vigil Light
Vigil Light14mo ago
I can fix that
dreadfullydistinct
dreadfullydistinctOP14mo ago
do you know what the issue is?
Vigil Light
Vigil Light14mo ago
Hi Are you there?
dreadfullydistinct
dreadfullydistinctOP14mo ago
Yes
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server