Closed
Description
AddMiniProfiler registers a type for MvcOptions and MvcViewOptions that can override or be overidden by another library.
Depending on what library is called first, the last registered type is used by MVC.
For example, FluentValidation does the same and conflicts with MiniProfiler, preventing ProfilingViewEngine from being used.
https://github.com/JeremySkinner/FluentValidation/blob/237ccfd581dcecf72209acdaabd4c41122fad98d/src/FluentValidation.AspNetCore/FluentValidationMvcExtensions.cs#L63
A workaround could be to register the ViewEngine using IServiceCollection.Configure()
services.Configure<MvcViewOptions>(options =>
{
for (var i = 0; i < options.ViewEngines.Count; i++)
{
options.ViewEngines[i] = new ProfilingViewEngine(options.ViewEngines[i]);
}
});
The same thing applies to MvcOptions which adds ProfilerActionFilter to the Filters collection. Here is my current workaround.
services.AddMvc(cfg =>
{
cfg.Filters.Add(new ProfilingActionFilter());
})