1

I'm having a problem installing a dev version of my Angular/Dotnet app to IIS. It seems like even when building the project as a dev/debug version and running it in IIS, the app informs me via a startup email I've created that it's always in production mode!

Steps to build and install in IIS:

  1. > ng build --debug -> builds files to a "wwwroot" folder in my dot net API project
  2. > dotnet publish --configuration Debug -> creates the publish folder with all files in bin folder
  3. copy and paste 'publish' folder files to IIS folder
  4. start the app in IIS manager -> see the site running in the browser

Now in my startup.cs file under the configure method, I have created this email code below to send me an email on startup. It's there to inform me if I'm in dev or prod mode. And it keeps saying production.

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        using (var client = new SmtpClient())
        {
            client.Host = email.host.com; 
            client.Port = 25; 
            client.EnableSsl = false;
            using (var emailMessage = new MailMessage())
            {
                emailMessage.To.Add(new MailAddress("myemailaddress@email.com"));
                emailMessage.From = new MailAddress("Startup@Somewhere.com");
                emailMessage.Subject = "Startup in: " + (env.IsDevelopment() ? "Development" : "Production");
                emailMessage.Body = "email body"; 
                client.Send(emailMessage);
            }
        }
     }

Am I building the projects incorrectly for dev?

chuckd
  • 13,460
  • 29
  • 152
  • 331
  • 1
    Debug or release build has nothing to do with the environment, https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1 – Lex Li Jan 15 '20 at 04:26
  • ok I think I see now. "ASPNETCORE_ENVIRONMENT" controls the dev or prod env. But I want to know what controls the appsettings.json/appsettings.Development.json files and which one is used? – chuckd Jan 15 '20 at 05:18
  • Again that's documented https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1 and you can do simple experiments to dig further into it. – Lex Li Jan 15 '20 at 06:35

0 Answers0