Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created May 23, 2021 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/0415a2e117d2b6458a8f3a09d6f06686 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/0415a2e117d2b6458a8f3a09d6f06686 to your computer and use it in GitHub Desktop.
.NET Core Web Applications - Handler Lifetime Setting
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