Reputation: 2073
I want to use the default MemoryCache
in a class or classes in a class library, and these classes will be used in both an ASP.NET website and via a Web.Api project in my solution. I know that to use the Default
cache I have to set configuration values because that cache instance doesn't get created using the constructor, as stated in MSDN.
I know that app and web.config files don't necessarily work as one expects (connection strings in EF for example), so I'm not sure if I can get away with putting the <memoryCache> configuration in just the app.config
in the class library, or if they have to be set in the web.config
in the different projects that the cache will be used in.
Will just using the class library's app.config
work here?
Thanks.
Upvotes: 0
Views: 609
Reputation: 2694
Simply using app.config of the library will not be enough. You need to put configuration values into configuration files of the "runnable" projects, as those files are used in runtime normally. By "runnable" I mean command line applications, windows services and ASP.NET websites.
So, you should put configuration into web.config files in both ASP.NET website and the WebApi project.
Upvotes: 2