How to configure environment variables in an IIS 7 application?

Solution 1:

Windows 7 SP1 introduced a new default setting for IIS that prevents the loading of profile specific environment variables for IIS application pools.

So, for Windows 7 SP1 you additionally need to edit the following file:

%windir%\system32\inetsrv\config\applicationHost.config

and add a processModel element with setProfileEnvironment set to true for your site app pool in the applicationPools section.

It should look like this:

<add name="ASP.NET v4.0" managedRuntimeVersion="v4.0">
      <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>

See Windows 7 SP1 causes IntelliTrace Collection to fail on IIS for more details.

Note: You should edit the applicationHost.config file with admin rights and after the change you should reboot the computer.