MVCCaching.Kentico.Core 13.0.2

.NET Core 3.1
Install-Package MVCCaching.Kentico.Core -Version 13.0.2
dotnet add package MVCCaching.Kentico.Core --version 13.0.2
<PackageReference Include="MVCCaching.Kentico.Core" Version="13.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MVCCaching.Kentico.Core --version 13.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MVCCaching.Kentico.Core, 13.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MVCCaching.Kentico.Core as a Cake Addin
#addin nuget:?package=MVCCaching.Kentico.Core&version=13.0.2

// Install MVCCaching.Kentico.Core as a Cake Tool
#tool nuget:?package=MVCCaching.Kentico.Core&version=13.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MVC Caching

MVC Caching for Kentico MVC, allows for easy Caching and hookup of Repository calls through IRepository, IService, and attributes found in the MVCCaching namespace. Sets up and leverages Kentico's cache dependencies.

Also tracks all Dependencies called to the ICacheDependenciesStore automatically, and you can leverage ICacheDependenciesScope.Begin() and string[] ICacheDependenciesScope.End() to begin and end tracking of dependencies in order to compile all dependencies between the begin and end.

Kentico 13 MVC.Net Core Installation

  1. Install the Nuget Package MVCCaching.Kentico.Core on your MVC.Net Core application. Note due to the complexity of invocation decoration, this package does depend on Castle Windsor and Autofac.

  2. On your Main method (usually Program.cs), to the HostBuilder, add .UserServiceProviderFactory(new AutofacServiceProviderFactory()) example:

public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                  // THIS ONE LINE BELOW NEEDED:
                 .UseServiceProviderFactory(new AutofacServiceProviderFactory())
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
  1. On your Startup Class Constructor method, add the following:
public Startup(IWebHostEnvironment environment)
        {
            Environment = environment;
            
            // MVC Caching
            var builder = new ConfigurationBuilder()
                .SetBasePath(environment.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                .AddJsonFile($"appsettings.{environment.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();
            this.Configuration = builder.Build();
            // END MVC Caching
        }
  1. Add these 2 methods to your Startup Class:
public IConfigurationRoot Configuration { get; private set; }
public ILifetimeScope AutofacContainer { get; private set; }
  1. Make sure for your Startup.ConfigureServices you have services.AddOptions(); called
  2. Add the following method to your Startup Class
// MVC Caching
public void ConfigureContainer(ContainerBuilder builder)
{
        DependencyResolverConfig.Register(builder, new Assembly[] { typeof(Startup).Assembly });
}

These steps hook up Autofac and MVC Caching.

NOTE: The "string currentCulture" and "bool previewEnabled" have been replaced with IRepoContext which you can leverage to retrieve these values.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
13.0.2 8,509 3/12/2021
13.0.0 1,975 11/13/2020

Added ICacheDependenciesStore and ICacheDependenciesScope integration.