When using MiniProfiler in an application hosted on multiple instances, MiniProfiler receives a 404 when POST is done to /mini-profiler-resources/results.
The reason is because the default implementation of the IStorage provider uses HttpRuntime.Cache. This cache is machine specific, and as a result instance B cannot access the MiniProfiler data saved on instance A.
This is an implementation of MiniProfiler.IStorage that uses the Azure distributed cache for temporarily saving results.
Using this couldn't be simpler, but does assume a few of things
- You have already have an Azure Cahe subscription
- You have the Azure Cache assemblies referenced in your project. The easiest way to do this is using the official nuget package
- You have the dataCacheClient configuration set in your config. The nuget package above will add this for you. You will just need to add your specific information to it.
- Copy the
AzureCacheStorage
file in the repo to your project. - Initialize a new instance of it into MiniProfiler.Settings.Storage. In an MVC application, this can be done in the
App_Start/MiniProfiler.PreStart()
method.
MiniProfiler.Settings.Storage = new AzureCacheStorage(TimeSpan.FromHours(1));