Created
February 20, 2021 17:28
-
-
Save shubhamnikam/b2fd0babd16d78c158f9341d6f6c8092 to your computer and use it in GitHub Desktop.
Setup HttpClient configuration in Startup.ConfigureService
This file contains hidden or 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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
//configure httpclient service | |
services.AddHttpClient("GithubAPI", client=> | |
{ | |
//customize as per your need | |
client.BaseAddress = new Uri("http://api.github.com/"); | |
client.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json"); | |
client.DefaultRequestHeaders.Add("User-Agent", "HttpClientFactoryExample"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment