C
C#2w ago
M!RFAN

Publish Profile Error

I have set <EnvironmentName>Development</EnvironmentName> and when published it has <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> in web.config but when running the application.exe it has no environment configured so defaults back to Production. Console.WriteLine($"{environment} - {JsonSerializer.Serialize(redisOptions)}"); => - xxxx (No Environment name is there)
3 Replies
Patrick
Patrick2w ago
web.config implies it's IIS if it's IIS why are you running the executable manually? web.config doesn't load into ASP.NET Core. You need to set an environment variable on the machine or use appsettings or explicitly configure a configuration source. If you're using IIS, you need to let the app pool load the website, and let IIS set the environment variable with the web.config as you have done. You do not manually load up the executable.
M!RFAN
M!RFANOP2w ago
First of all thanks and sorry for crossposting I want to check which environment it loads and it doesn't log in IIS so manually checking on local. Console.WriteLine($"{builder.Environment.EnvironmentName} - {Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")} - {JsonSerializer.Serialize(redisOptions)}"); for builder.Environment.EnvironmentName it returns Production and for ASPNETCORE_ENVIRONMENT its empty and I set the env value in iis configuration editor for application pool and the for system.webserver for aspnet its already set to Development but not working I have three appsettings.json - appsettings.json, appsettings.Development.json and appsettings.Production.json
Patrick
Patrick2w ago
as I said, you don't manually run the exe

Did you find this page helpful?