title: ASP.NET Core as a Windows Service - How to configure endpoints?
body: <p>I have an ASP.NET Core 3.1 web application which is hosted as a Windows Service on my machine. </p>
  
  <p>As per the <a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-3.1&amp;tabs=visual-studio#configure-endpoints" rel="nofollow noreferrer">documentation</a>, it says I can "configure the URL and port by setting the ASPNETCORE_URLS environment variable."</p>
  
  <p>Therefore I created the following System environment variable: </p>
  
  <p>Variable: ASPNETCORE_URLS </p>
  
  <p>Value: <a href="http://myapp.debug:5100" rel="nofollow noreferrer">http://myapp.debug:5100</a></p>
  
  <p>I tried a few variations of the above URL and port but when I run my ASP.NET Core application from Visual Studio and try to hit the URL nothing happens. </p>
  
  <p>How do I setup my own custom URL for my application? Is there anything else I'm missing? </p>
  
  <pre><code>public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
      Host.CreateDefaultBuilder(args)
          .UseWindowsService()
          .ConfigureServices((hostContext, services) =&gt;
          {
              services.AddHostedService&lt;Worker&gt;();
          })
          .ConfigureWebHostDefaults(webBuilder =&gt;
          {
              webBuilder.UseStartup&lt;Startup&gt;();
          })
          .ConfigureLogging(logging =&gt;
          {
              logging.ClearProviders();
              logging.SetMinimumLevel(LogLevel.Trace);
          })
          .UseNLog();
  </code></pre>