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'

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);
IHeaderDictionary Technology published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue


© 2021 - ErnesTech - Privacy