title: Can't get my Asp.Net Core project to work published to folder on localhost
body: <p>My Asp.Net Core 2.0 MVC app works fine when I run it from Visual Studio > IIS Express, but after I publish to folder (c:\inetpub\TSGOnline) (TSGOnline is my solution's name), I just see this error message in the browser:
  <a href="https://i.stack.imgur.com/n4Gfx.png" rel="nofollow noreferrer">It tells me that changing environment to Production, it will work</a></p>
  
  <p>But in Visual Studio, I have indeed set the ASPNETCORE_ENVIRONMENT to Production.
  <a href="https://i.stack.imgur.com/tIS8f.png" rel="nofollow noreferrer">As far as I can tell, the environment is Production</a></p>
  
  <p>My OS is Windows 10, IIS version is 10.0.15063.0.</p>
  
  <p>Program.cs:</p>
  
  <pre>
  
      using System.IO;
      using Microsoft.AspNetCore;
      using Microsoft.AspNetCore.Hosting;
      namespace TSGOnline
      {
          public class Program
          {
              public static void Main(string[] args)
              {
                  BuildWebHost(args).Run();
              }
  
              public static IWebHost BuildWebHost(string[] args) =>
                  WebHost.CreateDefaultBuilder(args)
                      .UseKestrel()
                      .UseContentRoot(Directory.GetCurrentDirectory())
                      .UseIISIntegration()
                      .UseStartup()
                      .Build();
          }
      }
  
  </pre>    
  
  <p>Startup.cs:</p>
  
  <pre>
  
      using Microsoft.AspNetCore.Builder;
      using Microsoft.AspNetCore.Hosting;
      using Microsoft.Extensions.Configuration;
      using Microsoft.Extensions.DependencyInjection;
      using TSGOnline.Models;
      using Microsoft.EntityFrameworkCore;
  
      namespace TSGOnline
      {
          public class Startup
          {
              public Startup(IConfiguration configuration)
              {
                  Configuration = configuration;
              }
  
              public IConfiguration Configuration { get; }
  
              // This method gets called by the runtime. Use this method to add services to the container.
              public void ConfigureServices(IServiceCollection services)
              {
                  services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
                  services.AddMvc();
              }
  
              // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
              public void Configure(IApplicationBuilder app, IHostingEnvironment env)
              {
                  if (env.IsDevelopment())
                  {
                      app.UseDeveloperExceptionPage();
                      app.UseBrowserLink();
                  }
                  else
                  {
                      app.UseExceptionHandler("/Home/Error");
                  }
  
                  app.UseStaticFiles();
  
                  app.UseMvc(routes =>
                  {
                      routes.MapRoute(
                          name: "default",
                          template: "{controller=TSG}/{action=Index}/{id?}");
                  });
              }
          }
      }
  
  </pre>
  
  <p>My csproj:
  <a href="https://i.stack.imgur.com/SiewN.png" rel="nofollow noreferrer">I wasn't able to paste it as code, so had to use image</a></p>
  
  <p>I have spent two days googling, trying to figure this one out, but being a total noob, I may not always know when the answers are right in front of me ... Please help?</p>