Orchardcore mini profiler

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore mini profiler is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for adding the MiniProfiler performance widget to Orchard Core front-end and admin pages. Covers enabling the feature, the ViewMiniProfilerOnFrontEnd and ViewMiniProfilerOnBackEnd permissions, widget placement in the Footer zone and docking on admin pages, shape rendering timings, YesSql SQL p

How to use this skill

Skill file

Orchard Core Mini Profiler - Prompt Templates

Add Performance Profiling

You are an Orchard Core expert. Enable and configure the MiniProfiler widget so authorized users can see request, shape, and database timings on Orchard Core pages.

Guidelines

Enabling Mini Profiler

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.MiniProfiler"
      ],
      "disable": []
    }
  ]
}

Granting Visibility to a Role

{
  "steps": [
    {
      "name": "Roles",
      "Roles": [
        {
          "Name": "Developer",
          "Permissions": [
            "ViewMiniProfilerOnFrontEnd",
            "ViewMiniProfilerOnBackEnd"
          ]
        }
      ]
    }
  ]
}

The Permissions

using OrchardCore.Localization;
using OrchardCore.Security.Permissions;

namespace OrchardCore.MiniProfiler;

public sealed class Permissions : IPermissionProvider
{
    public static readonly Permission ViewMiniProfilerOnFrontEnd =
        new("ViewMiniProfilerOnFrontEnd", LocalizationSource.Create<Permissions>("View Mini Profiler widget on front end pages"));

    public static readonly Permission ViewMiniProfilerOnBackEnd =
        new("ViewMiniProfilerOnBackEnd", LocalizationSource.Create<Permissions>("View Mini Profiler widget on back end pages"));

    // Both permissions default to the Administrator role via GetDefaultStereotypes().
}

Configure MiniProfiler

The module registers the upstream StackExchange.Profiling.MiniProfilerOptions in each tenant container. Configure them from the web project with ConfigureServices() after AddOrchardCms(). The module does not bind MiniProfilerOptions from configuration.

using StackExchange.Profiling;

builder.Services
    .AddOrchardCms()
    .ConfigureServices(tenantServices =>
        tenantServices.Configure<MiniProfilerOptions>(options =>
        {
            options.IgnoredPaths.Add("/health");
            options.PopupRenderPosition = RenderPosition.Right;

            // Protect stored results. MiniProfiler routes run before Orchard authentication,
            // so authenticate explicitly instead of relying on HttpContext.User.
            options.ResultsAuthorizeAsync = async request =>
            {
                var result = await request.HttpContext.AuthenticateAsync();

                return result.Succeeded && result.Principal.IsInRole("Administrator");
            };
        }));

Useful options to reduce overhead and noise:

The shape and YesSql integrations have no separate settings; they are active whenever the feature is enabled.

What You See

Storage and Multiple Instances

Results are kept in the tenant's in-memory cache for 30 minutes, are lost on restart, and are not shared between instances. Behind a load balancer use session affinity while diagnosing, or set MiniProfilerOptions.Storage to a shared IAsyncStorage from a MiniProfiler storage package (installed in the web project).

Custom Timings

using StackExchange.Profiling;

using (MiniProfiler.Current?.Step("Load recommendations"))
{
    await recommendationService.LoadAsync();
}

MiniProfiler.Current is null when the request is not profiled.

Troubleshooting

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.