1

I'm Talking to Okta support about a first call speed issue on my .net core 3.1 webapi that uses their security.

Their answer is to have the webapi, at startup, make a request to itself to force a failed okta authentication to "Prime the pump" before the first real call.

Is this even possible in a way not using a hardcoded url that will fail on promotion?

I could create a task to wait and have it do this:

using ( HttpClient client = new HttpClient() )
            {
                var httpRequest = new HttpRequestMessage( "GET", "https://localhost/SomeController" );
                return client.SendAsync( httpRequest );
            }

But it will fail on localhost... and to get the URL of the currently hosted webapi, I need to be IN a controller handling a request.

Is this even actually possible? let alone a good idea...? Their suggestion is to add curl to every server and then call a curl command...

curl --location --request GET 'https://localhost:50598/DoCThingssts?sAdName=lname.fnam' \
--header 'Authorization: Bearer eyJrasdfaWQiOiJ5QVFJUWZuRnpGeGZzdTdxY2tDasdfaasdfRnBnN09uOTZjTi1rMWc4YVEtREE3NTZNIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEasdfasdfIkFULmFiNEp6N3cyV2E0SGVNaHVkMV9sNExPVTI5MG44a2xsVHZiN1A4a3NjMzgiLCJpc3MiOiJodHRwczovL2pvYmNvcnBzLm9rdGFwcmV2aWV3LmNvbasdfXV0aDIvZGVmYXVsdCIsImF1ZCI6ImFwaTovL2RlZmF1bHQiLCJpYXQiOjE2NjQ5MDgasdfsdcCI6MTk2NDkasdfnNjcCI6WasdfMjAwLCJzdWIiOiJCaXNjaG9mZi5Eb25hbGRAbGl2ZS5qb2Jjb3JwcyasdfzBLntizxIVKoj7UKq6CUDPYFajWCSrQgVqCnjX6wrK1x3oWZjO4OHbKMkWRW43T_J-IBuGmgZYyEEWPEAYmH5To9H2vY4asdf4GQPb0YYzUvasdf'

Is there an actual clever way to make a webapi call itself after initialization has finished to "prime the pump"?

What event gets called when the service is all started up and "ready to go"?

kaylum
  • 13,833
  • 2
  • 22
  • 31
Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97

0 Answers0