Caching requires IDistributedCache
See original GitHub issueIf I try to turn on caching in the configuration I get the following error message
Caching is enabled, but no IDistributedCache is found in the services collection
Here’s the configuration:
public void ConfigureServices(IServiceCollection services) {
services.AddAuthentication(OAuth2IntrospectionDefaults.AuthenticationScheme)
.AddOAuth2Introspection(options => {
options.Authority = "https://myidentityserver";
options.ClientId = "myapi";
options.ClientSecret = "myapisecret";
options.EnableCaching = true;
});
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints => {
endpoints.MapControllers();
});
}
I don’t have my own IDistributedCache
, so shouldn’t there be some default implementation that IdentityModel uses if it doesn’t find one in the DI container?
IdentityModel.AspNetCore.OAuth2Introspection version 4.0.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Distributed caching in ASP.NET Core
A distributed cache is a cache shared by multiple app servers, typically maintained as an external service to the app servers that access...
Read more >Working with a Distributed Cache — ASP.NET documentation
A distributed cache is shared by multiple app servers (see Caching Basics). The information in the cache is not stored in the memory...
Read more >Working With ASP.NET 6 IDistributedCache Provider For ...
This is the interface required to access the distributed cache objects, which includes synchronous and asynchronous methods.
Read more >Caching in ASP.NET Core 3.1 using (IDistributedCache ...
A distributed cache is shared by multiple app servers. The information in a distributed cache is not available to just individual servers and...
Read more >Distributed Caching in ASP.NET Core with Redis
Today's objective is to leverage the IDistributedCache to do some distributed caching so that we can horizontally scale out our web app.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just for reference, to help anybody else out, as I stumbled upon the same:
In Asp.net Core 2.2 you probably called
services.AddMvc()
in Startup, which itself adds DistributedMemoryCache implicitely.In Asp.net Core 3.x, if you call only
services.AddControllers()
, the cache is not added by default. You have to add it explicitely, like by callingservices.AddDistributedMemoryCache()
.Hope that helps
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue.