{"record":{"id":"04ec416e3e05e505","repo":"microsoft/aspire","slug":"the-dashboard-is-not-enabled-for-this-application","errorCode":null,"errorMessage":"The dashboard is not enabled for this application.","messagePattern":"The dashboard is not enabled for this application\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs","lineNumber":80,"sourceCode":"    /// </code>\n    /// </example>\n    [AspireExportIgnore(Reason = \"Use the exported getDashboardUrl overload without a cancellation token.\")]\n    public static async Task<Uri> GetDashboardUrlAsync(\n        this DistributedApplication app,\n        CancellationToken cancellationToken = default)\n    {\n        ArgumentNullException.ThrowIfNull(app);\n\n        var executionContext = app.Services.GetRequiredService<DistributedApplicationExecutionContext>();\n        if (executionContext.IsPublishMode)\n        {\n            throw new InvalidOperationException(Properties.Resources.DashboardUrlPublishModeExceptionMessage);\n        }\n\n        var applicationOptions = app.Services.GetRequiredService<DistributedApplicationOptions>();\n        if (applicationOptions.DisableDashboard)\n        {\n            throw new InvalidOperationException(Properties.Resources.DashboardDisabledExceptionMessage);\n        }\n\n        ThrowIfNotStarted(app, Properties.Resources.DashboardUrlApplicationNotStartedExceptionMessage);\n        cancellationToken.ThrowIfCancellationRequested();\n\n        await app.ResourceNotifications.WaitForResourceHealthyAsync(\n            DashboardResourceName,\n            WaitBehavior.StopOnResourceUnavailable,\n            cancellationToken).ConfigureAwait(false);\n\n        var applicationModel = app.Services.GetRequiredService<DistributedApplicationModel>();\n        if (!applicationModel.Resources.TryGetByName(DashboardResourceName, out var resource) ||\n            resource is not IResourceWithEndpoints dashboardResource)\n        {\n            throw new InvalidOperationException(Properties.Resources.DashboardUrlUnavailableExceptionMessage);\n        }\n\n        var httpsEndpoint = dashboardResource.GetEndpoint(\"https\");","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs#L62-L98","documentation":"The Aspire dashboard can be disabled via DistributedApplicationOptions.DisableDashboard. GetDashboardUrlAsync requires a dashboard resource to resolve a URL, so it throws when the application was configured without one.","triggerScenarios":"Calling app.GetDashboardUrlAsync() when the AppHost was built with builder.Configuration or options setting DisableDashboard=true (or ASPIRE_DISABLE_DASHBOARD set), then attempting to fetch the dashboard URL.","commonSituations":"Test setups that disable the dashboard for speed or headless CI runs; apps configured with dashboard disabled for production-like runs but reusing testing helpers that assume it exists.","solutions":["Enable the dashboard (remove DisableDashboard=true / unset ASPIRE_DISABLE_DASHBOARD) if the URL is needed.","Guard the call: check applicationOptions.DisableDashboard before invoking GetDashboardUrlAsync.","Use resource endpoints directly instead of the dashboard URL when the dashboard is intentionally off."],"exampleFix":"// before\nvar url = await app.GetDashboardUrlAsync();\n// after\nvar opts = app.Services.GetRequiredService<DistributedApplicationOptions>();\nif (!opts.DisableDashboard)\n{\n    var url = await app.GetDashboardUrlAsync();\n}","handlingStrategy":"validation","validationCode":"var opts = app.Services.GetRequiredService<DistributedApplicationOptions>();\nif (opts.DisableDashboard)\n{\n    // dashboard is off; do not call GetDashboardUrlAsync\n}","typeGuard":"static bool DashboardEnabled(DistributedApplication app) =>\n    !app.Services.GetRequiredService<DistributedApplicationOptions>().DisableDashboard;","tryCatchPattern":"try\n{\n    var url = await app.GetDashboardUrlAsync(ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"dashboard is not enabled\"))\n{\n    url = null; // app intentionally runs without a dashboard\n}","preventionTips":["Only disable the dashboard in tests that never need its URL.","Unset ASPIRE_DISABLE_DASHBOARD in environments where dashboard-dependent tests run.","Centralize dashboard enable/disable configuration so tests can check it before calling."],"tags":["testing","dashboard","configuration"],"backgroundTag":"feature-not-enabled","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}