In my ASP.NET WebApi2 project, I decided to use the Strathweb.CacheOutput.WebApi2 package to provide caching and electronic tag functionality. However, after entering the CacheOutput attribute, I started getting an error:
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "WebApi.OutputCache.Core.Cache.IApiOutputCache", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, WebApi.OutputCache.Core.Cache.IApiOutputCache, is an interface and cannot be constructed. Are you missing a type mapping?
Obviously, the internal container DI container cannot be allowed by the cache provider.
How to use the attribute:
[HttpGet, Route("")]
[CacheOutput(ClientTimeSpan = 60 * 60 * 4, ServerTimeSpan = 60 * 60 * 4)]
public HttpResponseMessage Get(
string products,
int? startYear = null,
int? endYear = null,
int? drillDownYear = null,
int? drilldownMonth = null,
string callback = "")
{
...
}
Just to point out, I also use Unity in my application as a DI container.
source
share