-
Notifications
You must be signed in to change notification settings - Fork 58
Environment Variables from IIS auto added to web.config cause 502 when .net core 2 MVC app deployed #791
Comments
Which variable is breaking you? |
ANY env variable will stop the project working on the sever. Try it. |
is it inheriting a environmentVariables section from a parent app? There are some known issues with conflicts there. |
Just so I understand correctly. If you set a system environment variable and then set the same environment variable in your web.config, then you're broken? |
If I set an env variable in IIS on my dev machine (as detailed in my original comment), an environment variable is put in the web.config automatically. If you just then publish the site - the env variables are still in the published web config web.config. Having env variables in the web.config breaks the site on the server. When you delete them - the site then works. Visual Studio 2017 also puts other stuff in the web.config that also breaks it - you need to strip the web.config down to this to make it work:
|
@niico100 Show them the web.config you showed me that was breaking you that had the two env vars in it with the values redacted. |
Here is a web.config that was generated by Visual Studio 2017 Community when I published the project (after env variables added to IIS) - it causes a 502:
Having any env variables in the web.config has the same effect. |
... and IIRC during troubleshooting, we whittled down the <aspNetCore processPath="dotnet" arguments=".\MyApp.dll"
stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"> ... and it was still throwing until @niico100 removed those env vars. |
@niico100 There was an issue in Visual Studio where it modified your web.config. That has since been fixed in Visual Studio 2017 Update 15.7 This should no longer happen. |
I'm going to go close this issue. Please feel free to re-open if you continue to this behavior or if I misunderstood what you said. Thanks! |
This addresses part of the issue - but the environment variables issue remains and isn't addressed by this update. |
Also - we need to be clear about where the issue is here. Is the issue that the env variables are added to the web.config - or is the issue that having env variables in the web.config stops the app running on the server? (probably the latter?). |
I actually just tried that (in VS 15.7.1) - but I got a different error and have had to switch back to some other urgent work for now. (for what it's worth here's the new error - vanilla .net core 2 mvc solution, though it's probably not very relevant to this issue and happens regardless of env variables):
|
Yeah that seems like an issue with your application rather than ANCM. Running in VS will use IISExpress with a different aspnetcore.dll than the one used by IIS. When you get the chance, can you check the versions of aspnetcore.dll in C:\Windows\System32\inetsrv and C:\Program Files\IIS Express\ |
So right click C:\Windows\System32\inetsrv\aspnetcore.dll - and go to details / file version? 7.1.1990.0 I'm not using IIS Express locally I'm using full IIS (with env variable set) |
locally its 8.2.1991.0 |
btw @niico100 ... WRT that error. If it's a 2.0 project using the |
@shirhatti Sorry, but i'm still experiencing this problem with |
@shelland I don't believe what you're observing is related to the issue tracked here. Please file a new issue otherwise your concern going to be lost in the crowd here. |
@BillHiebert I was told that you implemented a workaround for this on tooling. What's it? |
cc @pan-wang please sync up with @BillHiebert on this. |
Which "this" are you referring to? The original issue where environment variables were being written into web.config is fixed. The -argfile IISExeLauncherArgs.txt is still an issue, as is any other ancm settings in web.config, unless publish fixes these settings when the application is published. |
One issue is about IISExeLauncherArgs.txt. For environment variables, I believe @jhkimnew had test covering it automatically. |
@shirhatti Do you know what's the latest on this? |
We haven't been able to repro @niico100's original issue. The only hypothesis I have on what could be going on is that thee version of ANCM on the server isn't new enough and hence it's failing at schema validation. @niico100 If you're still observing this issue, can you get back to us? Perhaps a FREB log can indicate where the 502 is even originating from |
Closing. Please reopen if there is more information about the issue. |
Create a new ASP.net Core 2 MVC template app. Set it up to use full IIS locally, add an environment variable; (I need to do this for AWS), the app runs fine locally on full IIS.
Publish to a server with IIS (Win Server 2012 R2 in my case, the web.config contains said environment variables). You get a 502, no stdout log or Event in Event Viewer is created. No helpful error message anywhere.
To get it working you need to delete the environment variables from the web.config - if you need environment variables you need to add them in IIS manually (IIS / [click site] / management / configuration editor / system.webServer / aspNetCore / environmentVariables)
cc @guardrex
The text was updated successfully, but these errors were encountered: