Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michele Benolli 31 posts 149 karma points
    Oct 28, 2021 @ 13:19
    Michele Benolli
    0

    Get content urls in a console application

    I am currently working on a console application running Umbraco, based on the code I found here. I can access Umbraco ContentService through the Current.Services.ContentService class. However, I do not know how to obtain the content Urls in this setup. UmbracoContext is null inside the console application. I tried with IUmbracoContextFactory.EnsureUmbracoContext() but a nullReferenceException is thrown. How can I do?

     class Program
     {
        static void Main(string[] args)
        {
            var application = new SidecarApplication();
            application.Start();
    
            var contentService = Current.Services.ContentService;
            var contentItems = contentService.GetRootContent(); // I need the Url of these contents
        }
    }
    
  • Bogdan 2 posts 72 karma points
    Oct 09, 2023 @ 14:31
    Bogdan
    0

    Hello Michele,

    I managed to make a console application work with Umbraco on .NET Core and I created a simple working example here:

    https://github.com/bcdragomir/Umbraco.Console

    It's not using Sidecar, just plain .NET stuff.

Please Sign in or register to post replies

Write your reply to:

Draft