Why are settings in web.config not inherited by child path applications?

Bob Rzadzki 16 Reputation points

I have a folder, Container, with a web.config file:

<?xml version="1.0" encoding="UTF-8"?>
                <environmentVariable name="gut_check" value="all good" />

and in Container/App, I have the published output of a .NET Core project with its own web.config:

<?xml version="1.0" encoding="utf-8"?>
  <location path=".">
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      <aspNetCore processPath="dotnet" arguments=".\App.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />

In the app, I retrieve the value of Configuration["gut_check"] and return it to the user. When I set this value on the command line, in the IDE's launch settings, or in App\web.config, this works as expected.

However, the setting in Container\web.config has no effect.

Expected result: Environment variables set in Container\web.config are inherited by the app in Container\App.

Is my expectation correct? Can I resolve this?

Microsoft Technologies based on the .NET software framework.
3,609 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
4,371 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,806 Reputation points Microsoft Vendor

    Hi @Bob Rzadzki,

    After my testing, I found that the current requirement cannot be achieved.

    First of all, we cannot add a asp.net core virtual application under the main asp.net core application. Then the two apps are independent and won't share environmentVariables.

    If you want use environment variable globally, please check this official doc.

    Windows - Set environment variable globally

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason Pan

    0 comments No comments