0

I've a .Net Core 3.1 web application published on IIS. I want to force enviroment type to development in order to run api that are not allowed in production.

I run the command :

setx ASPNETCORE_ENVIRONMENT "Development"

and then I run:

iisreset

as specified in this article How to set ASPNETCORE_ENVIRONMENT to be considered for publishing an ASP.NET Core application but the enviroment type seems to always remain production.

I try to run the API via a ngrok tunnel. Any suggestion? Thanks. Simone

  • Are you using IIS? Do you have a web.config file in the root of your site? There's ways to control the environment using the web.config, specifically [mentioned on the question you linked to](https://stackoverflow.com/a/41551429/1139830). – mason Sep 05 '22 at 22:52
  • @mason I'm using IIS and I've appsettings.json – Simone Spagna Sep 05 '22 at 22:57
  • Okay, but if you're using IIS, that means you've got a web.config file. Look at the root of your site, then follow the directions in the answer I linked you to, specifically see "Option 2" of their answer. – mason Sep 05 '22 at 23:35
  • Does this answer your question? [How to set ASPNETCORE\_ENVIRONMENT to be considered for publishing an ASP.NET Core application](https://stackoverflow.com/questions/41546943/how-to-set-aspnetcore-environment-to-be-considered-for-publishing-an-asp-net-cor) – mason Sep 05 '22 at 23:35

1 Answers1

1

You need to pass /M flag to setx command:

setx ASPNETCORE_ENVIRONMENT Development /M

The /M switch sets the environment variable at the system level. If the /M switch isn't used, the environment variable is set for the user account.

You can read more about it here

Aman B
  • 2,276
  • 1
  • 18
  • 26