Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

AspNetCoreModule – setting environment variables in web.config causes double entries with the same key (instead of overwriting existing ones) #235

Closed

Description

@gregkalapos

Environment

Windows 10, IIS with AspNetCoreModule hosting an Asp.NET Core application on top of full framework.

Steps to reproduce

Let’s say there are some existing environment variables already set on the system. In our case these were COR_ENABLE_PROFILING and COR_PROFILER. See screenshot.

setenvvar

In web.config we wanted to overwrite these settings like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\WebApplication4.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
      <environmentVariables>
        <environmentVariable name="COR_ENABLE_PROFILING" value="0x01" />
        <environmentVariable name="COR_PROFILER" value="{B7038F67-52FC-4DA2-AB02-969B3C1EDA03}" />        
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

I looked into the environment variables for the process with Process Explorer and as you see both values are added to the process.

processexplorer

Expected behavior

The environment variables set in the web.config should overwrite the existing ones.

Current workaround

I created a runWebapplication.bat file, with the following content and in the web.config I replaced processPath=".\WebApplication4.exe" by processPath=".\ runWebapplication.bat".

@echo off
SET COR_ENABLE_PROFILING=0x01
SET COR_PROFILER={B7038F67-52FC-4DA2-AB02-969B3C1EDA03}
WebApplication4.exe

Activity

  1. changed the title [-]AspNetCoreModule – settings environment variables in web.config causes double entries with the same key (instead of overwriting existing ones) [/-] [+]AspNetCoreModule – setting environment variables in web.config causes double entries with the same key (instead of overwriting existing ones)[/+] on Jul 18, 2016
  2. Tratcher commented on Jul 18, 2016

    @Tratcher
    Member

    Which one do you see in effect inside the process? The one from web.config should mask the system one, right?

  3. gregkalapos commented on Jul 18, 2016

    @gregkalapos
    Author

    The one from web.config should mask the system one, right?

    Yes, that is what I would expect, but in my case the system wide setting wins. And btw. when I use my own bat file Process Explorer shows only 1 entry (so in that case it is really overwritten).

    And another question: I guess all this is done by the aspnetcore module. Is that also opensource? I would look into that...

  4. added this to the 1.1.0 milestone on Aug 10, 2016
  5. muratg commented on Aug 10, 2016

    @muratg
    Contributor

    @pan-wang Any updates on this?

  6. shirhatti commented on Aug 16, 2016

    @shirhatti
    Contributor

    @muratg We will fix this in 1.1.0

    An environment variable defined in web.config will take precedence over the system environment variable

  7. gregkalapos commented on Aug 25, 2016

    @gregkalapos
    Author

    But why isn’t this part open source? Or I just did not find it?

  8. muratg commented on Aug 25, 2016

    @muratg
    Contributor

    @gregkalapos ANCM will be open source soon.

  9. pan-wang commented on Oct 11, 2016

    @pan-wang
    Contributor

    as scanning the variables are quite expensive, I changed the order of importing the environment variables, i.e., import user defined one first and then system ones. This will allow user to overwrite the system ones. The fix was checked in. It will be available at next release.

  10. muratg commented on Nov 7, 2016

    @muratg
    Contributor

    @pan-wang @shirhatti is this good to close?

  11. shirhatti commented on Nov 7, 2016

    @shirhatti
    Contributor

    Yes. This was fixed in v1.0.1969

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions