InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHeaderDictionary' while attempting to activate


Question: How do you resolve,

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHeaderDictionary' while attempting to activate 'HelperRepository'


Login to See the Rest of the Answer

Answer:
In this case, you are trying to use the IHeaderDictionary in a wrong way, do not inject IHeaderDictionary in a class Constructor instead instantiate the class that inherits from IHeaderDictionary which is Microsoft.AspNetCore.Http.HeaderDictionary(); then use the variable to add Headers to the response or request.

var _headers = new Microsoft.AspNetCore.Http.HeaderDictionary();
_headers.Add("MyAweseomHeader",ValueHere);






For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]