I am trying to register an instance of an HttpClient object with a unity container so that it can be used throughout the application, but when run in error - "The HttpMessageHandler type does not have an accessible constructor."
Here is the code I use to register HttpClient with Unity -
private static IUnityContainer BuildUnityContainer()
{
var container = new UnityContainer();
container.RegisterType<HttpClient>(
new InjectionProperty("BaseAddress", new Uri(ConfigurationManager.AppSettings["ApiUrl"])));
return container;
}
source
share