Can't get dynamic html page by using Self hosted AspNetCore MVC inside console app as Windows Service
<p>Problem: Need to be able to install and run Asp.Net MVC app (which returns a SPA angular app) as Windows Service</p>

<p>Subject: I'm using ASp.Net Core MVC inside Console app and run it as Windows service and it works perfectly fine (all requests are getting to the right place) but <code>return View();</code> returns empty page instead of the right html. </p>

<pre><code> public class Startup
{
    public IContainer ApplicationContainer { get; private set; }
    public IConfigurationRoot Configuration { get; private set; }

    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables();

        if (env.IsDevelopment())
        {
            // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
            builder.AddApplicationInsightsSettings(developerMode: true);
        }
        Configuration = builder.Build();

    }

    // This method gets called by the runtime. Use this method to add services to the container.
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddApplicationInsightsTelemetry(Configuration);
        services.AddMvc().AddWebApiConventions();

        services.AddCors();

        services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();

        var builder = new ContainerBuilder();
        builder.Populate(services);

        this.ApplicationContainer = builder.Build();
        return new AutofacServiceProvider(this.ApplicationContainer);
    }

    // This method gets called at the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        app.UseApplicationInsightsRequestTelemetry();
        app.UseApplicationInsightsExceptionTelemetry();

        var listener = app.ServerFeatures.Get&lt;WebListener&gt;();
        if (listener != null)
        {
            listener.AuthenticationManager.AuthenticationSchemes =
            AuthenticationSchemes.NTLM;
        }

        app.UseFileServer();
        app.UseCors(builder =&gt; builder.AllowAnyOrigin());

        app.UseMvc(routes =&gt;
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
            routes.MapWebApiRoute(
                name: "defaultApi",
                template: "api/{controller}/{action}/{id?}");
        });
    }
}

public class Program
{
    public static string ServiceName = "WebApp";

    static void Main(string[] args)
    {
        try
        {
            var exePath = Process.GetCurrentProcess().MainModule.FileName;
    //sure it's not necessary! It was just a try 
directoryPath = directoryPath.Replace("\\bin", "");
            var directoryPath = Path.GetDirectoryName(exePath);
            var httpAddress = "https://localhost";
            var httpPort = "10778";
            var host = new WebHostBuilder()
                .UseWebListener()
                .UseWebRoot(directoryPath + "\\wwwroot") //also just a try to navigate it right
                .UseContentRoot(directoryPath)
                .UseUrls($"{httpAddress}:{httpPort}")
                .UseStartup&lt;Startup&gt;()
                .Build();

            if (Debugger.IsAttached || args.Contains("--debug"))
            {
                host.Run();
            }
            else
            {
                host.RunAsService();
            }
        }
        catch (Exception ex)
        {
            var exMessage = ex.Message;
        }
    }
}
</code></pre>

<p>The sample project can be downloaded <a href="https://www.dropbox.com/sh/eb8gs2xhlnawpd6/AAD_nqWjWsVL3Bskm0fttd6xa?dl=0" rel="nofollow noreferrer">here</a></p>

<p><strong>UPDATE:</strong></p>

<p>After including  app.UseDeveloperExceptionPage(); into Configure method get such list of the errors </p>

<p><img src="https://i.stack.imgur.com/uL19v.png" alt="enter image description here"> </p>