0

I'm trying to access an API via Visual Basic from a gridview RowUpdating event on an aspx site.

I defined the corresponding sub as Async and get no errors or warnings, however once the called await function reaches the call to httpClient.GetDiscoveryDocumentAsync and check for the IsError property, I always get the error:

Error connecting to https://Example.org/.well-known/openid-configuration. Error while sending the request...

The code is pretty basic (of course with real Uri instead of example):

var httpClient = new HttpClient { BaseAddress = new Uri("Example.com") };

httpClient.Timeout = TimeSpan.FromMinutes(10);
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var disco = await httpClient.GetDiscoveryDocumentAsync("Example.com");
if (disco.IsError) throw new Exception(disco.Error);

I've rebuilt the complete code, including the actual call to the API, in independent projects, using C# as well as VB.Net, and the API calls go through in both projects. However, the exact same code, called from the aspx site, always runs into said error.

Could it be that it's a problem with the aspx environment? It's supposed to be a new feature on an old site, so it still runs on code behind, that's why I'm assuming the old structure prevents the call in some way.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Guddo
  • 1
  • 3

0 Answers0