Reputation: 51
I have implemented azure ad authentication in SPA app and validating the token using OWIN start.cs. it is working fine in local environment. below code used for token validation:
app.UseWindowsAzureActiveDirectoryBearerAuthentication(new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = tenant,
TokenValidationParameters = new TokenValidationParameters
{
//ValidAudiences = new[] { Audience },
ValidAudience = validateAudience,
ValidateIssuer = false,
ValidIssuers = new[] { ValidIssuers }
}
});
when I deployed this published code on prem server and run web api it throws error as mentioned in below screen shot. I have used Microsoft.Owin.Security.ActiveDirectory version 4.2.2.0,
can anyone help on this ?
Upvotes: 0
Views: 255
Reputation: 10831
Basically, the error task was canceled
is expected when an HTTP request is canceled maybe if the user closes the page suddenly.
or cancels before execution completes.
The TaskCanceledException is mostly timeout.But to check the exception, it may have to be inspected with try catch.
try
{
var response = task.Result;
}
catch (TaskCanceledException ex)
{
// Check ex.CancellationToken.IsCancellationRequested here.
// If false, we may assume it was a timeout in most cases.
}
you can try to suppress response if the cancellation token occurred by using if (cancellationToken.IsCancellationRequested)
HttpResponseMessage response = await base.SendAsync(request, cancellationToken);
if (cancellationToken.IsCancellationRequested)
{
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
}
return response;
If it is due to time out ,it can be set to some value.Plesae check the references.
var clientHttp = new HttpClient();
httpClient.Timeout = TimeSpan.FromMinutes(30)
In some cases of use , await
can be used for simultaneous tasks to be completed with async.
References:
Upvotes: 0