0

We create MemoryDistributedCache instance in Statup.ConfigureServices using

services.AddDistributedMemoryCache();
services.AddSession();

But how to access it scope of user action? E.g. administrator have changed user privileges and we should reset some sessions users data (privileges) stored there.

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142
  • 1
    Did you try to inject `IDistributedCache`? Because this extension method just registers `IDistributedCache`. See https://github.com/aspnet/Caching/blob/efbbdc5e0a8c8a664ea34cd41220d084b6906f57/src/Microsoft.Extensions.Caching.Memory/MemoryCacheServiceCollectionExtensions.cs#L76 – adem caglin Oct 29 '16 at 14:58
  • @ademcaglin Thank you. This should be a correct move. How I can inject it? In controllers constructor? – Roman Pokrovskij Oct 29 '16 at 15:01
  • Yes, you can inject it with controller constructor. – adem caglin Oct 29 '16 at 15:03
  • @ademcaglin, thank you, it works. May be you can reply on more geniral quesiton? How to get from container information which interfaces can be injected through constructor? It is now like a hidden part of api.. – Roman Pokrovskij Oct 29 '16 at 15:47

0 Answers0