csharp check if env is development 1

csharp check if env is development

bool isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development";

Here is what the above code is Doing:
1. We’re using the `Environment` class to get the value of the `ASPNETCORE_ENVIRONMENT` environment variable.
2. We’re checking if the value of the `ASPNETCORE_ENVIRONMENT` environment variable is equal to `Development`.
3. If the value of the `ASPNETCORE_ENVIRONMENT` environment variable is equal to `Development`, then we’re setting the `isDevelopment` variable to `true`.
4. If the value of the `ASPNETCORE_ENVIRONMENT` environment variable is not equal to `Development`, then we’re setting the `isDevelopment` variable to `false`.

Now that we have the `isDevelopment` variable, we can use it to determine whether or not we should use the `UseDeveloperExceptionPage` middleware.

Let’s add the following code to the `Configure` method:

Similar Posts