Base solution for your next web application
Open Closed

Change ASPNETCORE_ENVIRONMENT in launchSettings.json #11131


User avatar
0
PDV created

Hi,

these are the prerequisites:

  • v11.2.1
  • ASP.NET CORE & Angular
  • .NET 6

I downloaded the newest version, created a new database, applied the migrations, and started the Web.Host project. So far is everything ok. The problem starts when I change the ASPNETCORE_ENVIRONMENT in launchSettings.json to something different than "Development", e.g. to "Staging", "Production" or "Localhost". I also made sure that the ConnectionString and the ServerRootAddress in the corresponding appsettings.[ASPNETCORE_ENVIRONMENT].json file is correct . But as you can see from the screenshots below, I get a 404 page, and the AbpModuleManager does not load the modules as it seems. I wanted to upgrade from v7.0.0 to v11.2.1, and in v7.0.0 I don't have this problem.

Default launchSettings.json:

appsettings.json:

Logs when started with ASPNETCORE_ENVIRONMENT "Development"

Edited launchSettings.json:

appsettings.Staging.json

Logs when started with ASPNETCORE_ENVIRONMENT "Staging":

Website:


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you go to https://localhost:44301/swagger and see if it works ? I think the app works correctly. The problem might be in HomeController of the Host app.

  • User Avatar
    0
    PDV created

    Yes, the app works. Seems like it is only the redirection that is not working

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @pdv

    If you are not planning to host your Angular and API (Host app) together under the same website, you can modify the HomeController and remove the related code part.

  • User Avatar
    0
    PDV created

    Angular and API are hosted on different websites, we did not know that it is possible to host it on the same website. So now that we know it, it is possible to consider it for the future and that's why I decided not to change the HomeController. However, the same result can be achieved by changing the HomePageUrl in appsettings.json. With the changed HomePageUrl it is now working again.

    Original settings: Changed settings: