I am trying to cache a Blazor component using .Net 7 and AuthenticationStateProvider as my means of authorization. I have followed the tips on this page: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/output?view=aspnetcore-7.0 when it comes to registering the services and looked at this page: OutputCache attribute not working on .NET 7 API endpoint as far as creating your custom caching when using the "[Authorize]" attribute. However, in my case I am using the AuthenticationStateProvider. Therefore, I am just wondering how get that going using this method. Here's how I had in my Program.cs:
//Cache
builder.Services.AddOutputCache(options =>
{
options.AddBasePolicy(builder => builder.Expire(TimeSpan.FromMinutes(2)).Cache());
});
app.UseStaticFiles();
app.UseRouting();
app.UseOutputCache();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
And here's I had applied to my partial class in the component:
[OutputCache]
public partial class MyClass
{
}
Thanks in advance!