Skip to content

Instantly share code, notes, and snippets.

@readingdancer
Last active July 2, 2025 20:20
Show Gist options
  • Select an option

  • Save readingdancer/b3604395b2f713305e8a919144c3237c to your computer and use it in GitHub Desktop.

Select an option

Save readingdancer/b3604395b2f713305e8a919144c3237c to your computer and use it in GitHub Desktop.
Add clickable Umbraco URL to terminal output when running locally
// Add this to your program.cs file.
// Output the Umbraco URL for easy access (only when running on localhost)
app.Lifetime.ApplicationStarted.Register(() =>
{
var configuration = app.Services.GetRequiredService<IConfiguration>();
var urls = configuration["ASPNETCORE_URLS"] ?? configuration["urls"];
// Check if we have localhost URLs or fallback to checking app.Urls
var allUrls = new List<string>();
if (!string.IsNullOrEmpty(urls))
{
allUrls.AddRange(urls.Split(';'));
}
allUrls.AddRange(app.Urls);
var localhostUrl = allUrls.FirstOrDefault(url => url.Contains("localhost"));
if (localhostUrl != null)
{
var umbracoUrl = $"{localhostUrl}/umbraco";
var logger = app.Services.GetRequiredService<ILogger<Program>>();
logger.LogInformation("Umbraco is running at: {UmbracoUrl}", umbracoUrl);
Console.WriteLine($"Umbraco is running at: {umbracoUrl}");
}
});
@readingdancer
Copy link
Author

When you run your Umbraco site using dotnet run you will then get the following output in the terminal window that you can then easily click on to open Umbraco :)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment