I tried following the answer (highest voted, not accepted) found here to implement ResponseCaching
in my asp.net core 2.0 project.
However I get the error:
InvalidOperationException: Cannot resolve scoped service 'Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCachingPolicyProvider' from root provider. Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, ServiceProvider serviceProvider)
The steps I've taken are:
1 Add the Interface binding in Startup like so:
services.AddScoped<IResponseCachingPolicyProvider, ResponseCachingPolicyProvider>();
2 Add the response caching middleware like so:
public void Configure(IApplicationBuilder application)
{
application
.UseResponseCaching()
.UseMvc();
}
3 Added the Tag to my Controller like so:
[ResponseCache(Duration = 3600)]
I am trying to get the same behaviour as adding [OutputCache(NoStore = true, Duration = 0)]
Wouldve had in the past asp.net versions.