locked
.Net Core 2.0 app runs fine locally, gets Development mode error when deployed RRS feed

  • Question

  • User-2006371901 posted

    I have a .Net Core 2.0 app that runs locally with an appsettings.json , appsettings.development.json config files, but no web.config. It works fine when testing on localhost, but when uploading to the server (shared host), it renders this error:

    Error.
    An error occurred while processing your request.
    Request ID: 0HLO9VLG9MIR9:00000002

    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.

    very confusing as this is different than aspnet mvc .Can't find an answer anywhere, including the host providers.
    ??
    Ned



    Tuesday, July 16, 2019 3:43 PM

All replies

  • User-474980206 posted
    You can set environment variables in web.config, where you configure the aspnet core hosting module.

    https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2

    Tuesday, July 16, 2019 4:22 PM
  • User1120430333 posted

    https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-enable-debugging-for-aspnet-applications?view=vs-2017

    You can use LocalIIS on your development machine and debug the project, which is the same IIS on the shared host. I am not talking about localhost IIS Express. 

    Tuesday, July 16, 2019 4:23 PM
  • User-2006371901 posted

    This was built in Visual Code, which did not render a web.config file.
    HTH
    Ned

    Tuesday, July 16, 2019 4:26 PM
  • User-474980206 posted

    if hosted by IIS there is a web.config that configures the core hosting module. The error just says if dev mode is enabled you will get more error info. Your just rebuild the app to always use the developer error page (just take out the if).

    to help more we need to know the hosting environment, windows, linux, etc. if II which version of the core module yo are using.

    Tuesday, July 16, 2019 7:18 PM
  • User-2006371901 posted

    if hosted by IIS there is a web.config that configures the core hosting module. The error just says if dev mode is enabled you will get more error info. Your just rebuild the app to always use the developer error page (just take out the if).

    to help more we need to know the hosting environment, windows, linux, etc. if II which version of the core module yo are using.



    This was borrowed from a Visual Code app. It came with no web.config, ...I don't understand "always use the developer error page(just take out the if)

    This app is aspnet core 2.0 , it works fine locally, as far as live/production, it goes on a windows server that is shared hosting.

    HTH

    Ned

    Tuesday, July 16, 2019 8:06 PM
  • User475983607 posted

    The openly published ASP.NET Core documentation explains the details.  When you deploy an ASP.NET Core application to an IIS host, the process creates a web.config that IIS uses to fire up and communicate with the Core application (out-of-process). 

    https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/?view=aspnetcore-2.2

    The web.config can contain an environment setting which tells the Core application which appSettings.config to use. 

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.2

    We have no idea what platform you targeted so we have no way to provide actuate assistance at this point but I'm assuming IIS.

    With all that being said, the error message is standard and it is telling you that if you configure the app to run in Development mode, you'll get a more descriptive error message.  By default an ASP.NET Core application will run in Production mode unless otherwise told to run in a different environment.

    Tuesday, July 16, 2019 8:42 PM
  • User-474980206 posted

    you should try reading the code something.

    in startup.cs you will find:

                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
           

    if you comment out the "if" you will get the the developer exception page that the error is suggesting without having to set the environment variable.

    Tuesday, July 16, 2019 11:02 PM