Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core deployment to IIS error: Development environment should not be enabled in deployed applications

I followed this article to deploy my ASP.NET MVC Core 1.0 app to local IIS on my Windows 10 that is using IIS 10. The application deployed successfully and it opens the home page fine. I'm using Individual User Accounts Authentication. On the home page when I enter login/password and click Login button, I get the following error. I'm using the latest versions of ASP.NET Core and VS2015. I used VS2015 Publish wizard to publish the app. Everything is done on the same machine:

An error occurred while processing your request.

Development Mode

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.

like image 633
nam Avatar asked Sep 28 '16 03:09

nam


People also ask

How do I fix the development environment shouldn't be enabled for deployed applications?

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.

How do I enable developer mode in IIS?

Development Mode For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.


2 Answers

First, check the value of ASPNETCORE_ENVIRONMENT variable. You will have to set this environment variable to "Production" (or other environment than Development)

Otherwise, you can update web.config like this-

<configuration>   <!--     Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380   -->   <system.webServer>     <handlers>       <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />     </handlers>     <aspNetCore processPath=".\Application.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">       <environmentVariables>         <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />       </environmentVariables>     </aspNetCore>   </system.webServer> </configuration> 

Refer this post for more details.

like image 66
Sanket Avatar answered Sep 19 '22 15:09

Sanket


I wanted to run it in development environment, so I added following in web.config file, and it worked for me:

<environmentVariables>      <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables> 

enter image description here

like image 29
Deep Avatar answered Sep 19 '22 15:09

Deep