aliostad / CacheCow

An implementation of HTTP Caching in .NET Core and 4.5.2+ for both the client and the server
MIT License
847 stars 172 forks source link

Exception on Startup #297

Closed duduccosta closed 6 months ago

duduccosta commented 6 months ago

Hello.

I'm getting the follow error:

Error while validating the service descriptor 'ServiceType: CacheCow.Server.ICachingPipeline Lifetime: Transient ImplementationType: CacheCow.Server.CachingPipeline': Unable to resolve service for type 'CacheCow.Server.HttpCachingOptions' while attempting to activate 'CacheCow.Server.CachingPipeline'. Unable to resolve service for type 'CacheCow.Server.HttpCachingOptions' while attempting to activate 'CacheCow.Server.CachingPipeline'.

I'm using CacheCow.Server.WebApi 2.13.1. .NET Version = 7

Occours at: services.AddTransient<ICachingPipeline, CachingPipeline>();

Using AddHttpCaching(): image

Controller: image

Thanks.

aliostad commented 6 months ago

Hi Thanks for raising this. I will look into it.

aliostad commented 6 months ago

Sorry for the delay I did not have visual studio (I lost motherboard and sent for replace) but now I got it.

aliostad commented 6 months ago

OK, it seems that you have not configured the service in any way.

You need to consider options you wanna take and based on that provide implementations.

But since you are using Core MVC flavour rather than the classic Web API, you just need to use AddHttpCachingMvc() rather than AddHttpCaching() which is for the classic case.

If you fairly new to .NET space, before there was Core MVC Web API, there was a Web API and AddHttpCaching() is intended for that.

If you come across other problems let me know.