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: It tells me that changing environment to Production, it will work
But in Visual Studio, I have indeed set the ASPNETCORE_ENVIRONMENT to Production. As far as I can tell, the environment is Production
My OS is Windows 10, IIS version is 10.0.15063.0.
Program.cs:
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(); } }
Startup.cs:
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?}"); }); } } }
My csproj: I wasn't able to paste it as code, so had to use image
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?