microsoft/aspire · error · InvalidOperationException
BrowserMessageStrings.BrowserLogsResourceMissingHttpEndpoint
Error message
BrowserMessageStrings.BrowserLogsResourceMissingHttpEndpoint
What it means
WithBrowserLogs requires the target resource to expose an HTTP or HTTPS endpoint; the builder scans the resource's EndpointAnnotations (preferring https, falling back to http) to derive the URL for the tracked browser. If no endpoint with either scheme exists, it throws this InvalidOperationException naming the resource.
Solutions
- Add an http or https endpoint to the resource (WithHttpEndpoint / WithEndpoint with UriScheme http(s)).
- Apply WithBrowserLogs to the actual web project resource instead of a non-HTTP resource.
- If using a custom endpoint, set its scheme to http or https.
Example fix
// before
var frontend = builder.AddProject<Projects.Frontend>("frontend").WithBrowserLogs(); // no endpoint declared
// after
var frontend = builder.AddProject<Projects.Frontend>("frontend")
.WithHttpEndpoint(port: 5000)
.WithBrowserLogs(); Defensive patterns
Strategy: validation
Validate before calling
// Confirm the resource exposes an http/https endpoint before enabling browser logs
bool HasHttpEndpoint(IResource r) => r.Annotations.OfType<EndpointAnnotation>()
.Any(e => e.UriScheme is "http" or "https");
if (!HasHttpEndpoint(frontend)) throw new InvalidOperationException("WithBrowserLogs requires an http/https endpoint."); Try / catch
try { frontend.WithBrowserLogs(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("endpoint", StringComparison.OrdinalIgnoreCase)) { logger.LogError(ex, "Resource {Name} has no http/https endpoint for browser logs.", frontend.Resource.Name); } Prevention
- Always declare WithHttpEndpoint/WithEndpoint on resources you attach WithBrowserLogs to.
- Only apply WithBrowserLogs to web resources, not workers or databases.
- Keep endpoint schemes as http/https for browser-facing resources.
When it happens
Trigger: Calling builder.WithBrowserLogs(...) on a resource that has no http/https endpoint — e.g. a worker/process resource, a database, or a web project that never declared WithEndpoint/WithHttpEndpoint.
Common situations: Applying WithBrowserLogs to a non-HTTP resource by mistake; a frontend project missing its endpoint declaration; endpoint defined with a custom scheme (tcp, ws) instead of http/https.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not create for resource ' ' as the endpoint with name…
- Could not create for resource ' ' as no endpoint was found…
- Could not create HTTP command for resource
- A SearchIndexClient could not be configured. Ensure valid…
- BrowserMessageStrings.BrowserLogsEndpointNotAllocated
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/40e0236c20e94df9.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Browsers/BrowserLogsBuilderExtensions.cs:330
new ResourcePropertySnapshot(BrowserSessionsPropertyName, "[]"),
new ResourcePropertySnapshot(TotalSessionsLaunchedPropertyName, 0)
]);
return [.. properties];
}
static Uri ResolveBrowserUrl(T resource)
{
EndpointAnnotation? endpointAnnotation = null;
if (resource.TryGetAnnotationsOfType<EndpointAnnotation>(out var endpoints))
{
endpointAnnotation = endpoints.FirstOrDefault(e => e.UriScheme == "https")
?? endpoints.FirstOrDefault(e => e.UriScheme == "http");
}
if (endpointAnnotation is null)
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsResourceMissingHttpEndpoint, resource.Name));
}
var endpointReference = resource.GetEndpoint(endpointAnnotation.Name);
if (!endpointReference.IsAllocated)
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsEndpointNotAllocated, endpointAnnotation.Name, resource.Name));
}
return new Uri(endpointReference.Url, UriKind.Absolute);
}
static void ThrowIfBlankWhenSpecified(string? value, string paramName)
{
if (value is not null)
{
ArgumentException.ThrowIfNullOrWhiteSpace(value, paramName);
}
}View on GitHub (pinned to 25830f84bd)