HttpClient .NET的最佳实践是什么?

时间:2017-07-05 12:05:08

标签: .net asp.net-web-api singleton httpclient

使用HttpClient .NET创建Web api客户端的最佳实践是什么,并将其用作父类?使用“post,get,put,delete”方法,配置HttpClient并处理异常..

例如:

public class ProductClient : BaseHttpClient
{
    public IList<TeamHeader> RetrieveAllProducts()
    {
        return BaseHttpClient.Get<IList<Product>>("WebApi/Product/GetProducts");
    }
}

或者可以推荐单个类的HttpClient?

0 个答案:

没有答案