{"record":{"id":"3ea0e689fa13d332","repo":"microsoft/aspire","slug":"the-dashboard-url-is-not-available","errorCode":null,"errorMessage":"The dashboard URL is not available.","messagePattern":"The dashboard URL is not available\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs","lineNumber":95,"sourceCode":"        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\");\n        var httpEndpoint = dashboardResource.GetEndpoint(\"http\");\n        var dashboardEndpoint = httpsEndpoint.Exists ? httpsEndpoint : httpEndpoint;\n        if (!dashboardEndpoint.Exists)\n        {\n            throw new InvalidOperationException(Properties.Resources.DashboardUrlUnavailableExceptionMessage);\n        }\n\n        var dashboardUrl = await EndpointHostHelpers.GetUrlWithTargetHostAsync(dashboardEndpoint, cancellationToken).ConfigureAwait(false);\n        if (string.IsNullOrEmpty(dashboardUrl))\n        {\n            throw new InvalidOperationException(Properties.Resources.DashboardUrlUnavailableExceptionMessage);\n        }\n\n        var browserToken = app.Services.GetRequiredService<IConfiguration>()[\"AppHost:BrowserToken\"];\n        if (!string.IsNullOrEmpty(browserToken))","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs#L77-L113","documentation":"After the app starts, GetDashboardUrlAsync looks up a resource named 'dashboard' in the application model and requires it to expose endpoints. If the model has no such resource or it implements no endpoints, no dashboard URL can be derived and this error is thrown.","triggerScenarios":"Calling GetDashboardUrlAsync on an app whose DistributedApplicationModel lacks the dashboard resource (added automatically only in run mode with dashboard enabled) or whose dashboard resource has no endpoints registered.","commonSituations":"Calling before the model is fully built/started; custom AppHosts that suppress or rename the dashboard resource; non-Aspire execution paths (e.g. running via dotnet run without the DCP wiring).","solutions":["Ensure the app is started (await app.StartAsync()) and wait for the dashboard resource to be created before fetching the URL.","Verify the dashboard resource exists: app.Services.GetRequiredService<DistributedApplicationModel>().Resources.Any(r => r.Name == \"dashboard\").","Re-enable the dashboard if it was disabled via configuration.","Check you are running in run mode (not publish) so the dashboard resource is materialized."],"exampleFix":"// before\nvar url = await app.GetDashboardUrlAsync();\n// after\nawait app.ResourceNotifications.WaitForResourceAsync(\"dashboard\", KnownResourceStates.Running);\nvar url = await app.GetDashboardUrlAsync();","handlingStrategy":"validation","validationCode":"var model = app.Services.GetRequiredService<DistributedApplicationModel>();\nvar ready = model.Resources.TryGetByName(\"dashboard\", out var r) && r is IResourceWithEndpoints;\nif (!ready)\n{\n    // dashboard resource missing or has no endpoints; wait or bail out\n}","typeGuard":"static bool HasDashboardResource(DistributedApplication app) =>\n    app.Services.GetRequiredService<DistributedApplicationModel>()\n        .Resources.TryGetByName(\"dashboard\", out var r) && r is IResourceWithEndpoints;","tryCatchPattern":"try\n{\n    var url = await app.GetDashboardUrlAsync(ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not available\"))\n{\n    url = null; // dashboard resource absent from the model\n}","preventionTips":["Call GetDashboardUrlAsync only after StartAsync completes.","Run in run mode so the dashboard resource is added to the model.","Do not remove or rename the dashboard resource in custom AppHosts."],"tags":["testing","dashboard","resource-endpoints"],"backgroundTag":"resource-not-found","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"}