Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • Sounds good, but IHttpClient, How would I ensure I create a valid Interface for HttpClient... an Interface can't inherit from a HttpClient... Do I need to create Interface manually ? Commented Sep 10, 2013 at 16:11
  • Do you have an example ? Commented Sep 10, 2013 at 16:12
  • 1
    I've added an example. Commented Sep 10, 2013 at 16:27
  • 1
    This seems like an incomplete solution to me. The problem is that in the question the HttpClient gets new-ed up inside a method, which means a new one is needed every time. Therefore, injecting a wrapper which provides a single HttpClient also inside it's constructor is treating the HttpClient as a singleton, which is incorrect. In order to provide a per-instance HttpClient I think we need to inject something like a factory which creates HttpClients (or IHttpClient) on request. Commented Nov 25, 2014 at 16:36
  • 1
    HttpClient does not need to be disposed according to its developers even though it implements the IDisposable interface. So you don't need the IDisposable. Commented Jul 27, 2015 at 9:34