1

My project is in .Net Core 1.1 and cosmosDB backend. We are using Auth0 as authentication. After login, user can enter data and save it in there MANAGE PAGE. While saving we are storing user name (most of the time its a Email address) in the same record. Everything working fine. But for some users I'm getting this error,

Swapping to Development environment will display more detailed information about the error that occurred. Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

I checked in SO and some other blogs. As they suggest to change the ASPNETCORE_ENVIRONMENT to Production in lunchSettings.json in the project. But there is no luck.

What I'm doing, everytime I changed my code in development, I commit my code to SVN then Publish it, like everyone do.

Note: I don't have web.config file and I dont want to add that manually.

the error

Basanta Matia
  • 1,504
  • 3
  • 15
  • 27
  • Thanks for quick response. Yes! I'm using that. It's here `if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); }` – Basanta Matia Sep 19 '17 at 07:37
  • Sorry, but this is too broad. What exactly you want to achieve? Do you need to see what the exact error you have on production env? If yes - then you should look into adding some logging for unhandled exceptions etc. There are a lot of examples how to handle this. And you don't need to play with ASPNETCORE_ENVIRONMENT in this case. If you want to show a different error message to end user, then play with `UseExceptionHandler` and use different/modify current ErrorView. As you see in your code for Dev env it uses `UseDeveloperExceptionPage()` and this is unsafe to use for production. – Set Sep 19 '17 at 08:13
  • My only question is how to override this ? Why it's coming for some users, not for all. I have set **ASPNETCORE_ENVIRONMENT to Production**, still why it's coming. – Basanta Matia Sep 19 '17 at 08:15
  • You have an error for some users not cause you set `ASPNETCORE_ENVIRONMENT=Production`, but because you have some internal bug that is not 100% reproducible. Above error doesn't say how to fix the problem, it just says that if you switch to `ASPNETCORE_ENVIRONMENT=Development` due to this code in your app `if (env.IsDevelopment()) {app.UseDeveloperExceptionPage(); ..` it may shows you more detailed error (with some stacktrace and so on). You should find what is the exact error (using logs, finding how to reproduce locally, etc), – Set Sep 19 '17 at 08:18
  • And how are you hosting/serving your application? Are you running it from your IDE, or is it a published website? Is it IIS? – Jakub Szumiato Sep 19 '17 at 08:32
  • We have hosted in Azure. – Basanta Matia Sep 19 '17 at 08:35

1 Answers1

1

Knowing that you are not running your application in debug, but rather published it on Azure (as posted in comment) you have to change your environment variable in Azure. launchSettings.json is not meant for that.

I have found an answer which is describing how to configure it on Azure, so I won't be repeating here: How and where to define an environment variable on azure

Hope that helps.

Jakub Szumiato
  • 1,318
  • 1
  • 14
  • 19