dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.92k stars 479 forks source link

Can dashboard commands return a URL to be opened in the browser #6173

Open samsp-msft opened 1 month ago

samsp-msft commented 1 month ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

Dashboard commands are one of the ways a host/dcp can offer up functionality. But AFAIK today we dont have the ability for the command to essentially communicate back with the host, get a url and then have that opened as a new tab.

Describe the solution you'd like

This would make it much easier for the host to be able to programmatically generate a URL with whatever other context it may need, such as security tokens, and then respond to the dashboard which can then use that to spawn a new tab.

Additional context

No response

JamesNK commented 1 month ago

Right now there is a CommandResults.Success() helpr method that's called at the end of the command. The intention is in the future we add supporting for opening a browser URL (or other actions) by returning a different result, e.g. CommandResults.Success(launchUrl: "http://helloworld") or CommandResults.LaunchBrowser("http://helloworld"). I'm not sure how well that would work in practice as I think browser popup blockers might block it.

We might work around that by launching the browser window directly from .NET. You can do that today inside the command using Process, e.g. Process.Start("http://helloworld").