0

I set my environment variables for each web site to development mode, but I am still not getting detailed error messages. Instead, I am getting a message that:

Swapping to Development environment will display more detailed information about the error that occurred.

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app."

launchsettings.json:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:50802",
      "sslPort": 44399
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "FazalElectronics": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    }
  }
}

Startup.cs

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
  if (env.IsDevelopment())
  {
    app.UseDeveloperExceptionPage();
    app.UseDatabaseErrorPage();
  }
  else
  {
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
  }
  app.UseHttpsRedirection();
  app.UseStaticFiles();

  app.UseRouting();

  app.UseAuthentication();
  app.UseAuthorization();

  app.UseEndpoints(endpoints =>
  {
    endpoints.MapControllerRoute(
      name: "default",
      pattern: "{controller=Home}/{action=Index}/{id?}");
      endpoints.MapRazorPages();
  });
}

Error Message: Screenshot of error message

One thing is especially confusing to me: When I publish my app to the server, I get an additional appsetting.production.json file, but I don't have any idea what it does.

Community
  • 1
  • 1
Alamzaib Farooq
  • 190
  • 2
  • 18
  • You are using ASPNETCORE_ENVIRONMENT same for both, Check if this is making issue here – Anirudha Gupta Oct 15 '19 at 16:26
  • Possible duplicate of [Asp.Net Core Hosting environment variable ignored](https://stackoverflow.com/questions/40085077/asp-net-core-hosting-environment-variable-ignored) – mxmissile Oct 15 '19 at 16:41

0 Answers0