Created
May 23, 2021 20:36
-
-
Save manoj-choudhari-git/0415a2e117d2b6458a8f3a09d6f06686 to your computer and use it in GitHub Desktop.
.NET Core Web Applications - Handler Lifetime Setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddHttpClient<GitHubApionsumer>(c => | |
{ | |
c.BaseAddress = new Uri("https://api.github.com/"); | |
// Github API versioning | |
c.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json"); | |
// Github requires a user-agent | |
c.DefaultRequestHeaders.Add("User-Agent", "theCodeBlogger.com Demo"); | |
}).SetHandlerLifetime(new TimeSpan(0, 10, 0)); // Handler Lifetime is set to 10 minutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment