.Net 8 Web Api Config
Deployed webapi in IIS. Previously using .net 4.5.* where changing config in application settings in UI and restarting for dynamic change. Now in .Net 8 using Environment.GetenvironmentVariable, on publishing generated web.config file but adding values doesn't reflect and added values to pool also none but when added to system level it works but it takes time to recognise. Tried ChatGPT and older relevant question here and none working can someone point me in the best direction? TIA
25 Replies
Could you elaborate? I didn't understand anything
In my .net 8 webapi, I'm using Environment.GetEnvitonmentVariable to get some env values
While on development those values are stored in launchsettings.json but now after publishing to IIS, how to set those environment variables
Stack Overflow
Publish to IIS, setting Environment Variable
Reading these two questions/answers I was able to run an Asp.net 5 app on IIS 8.5 server.
Asp.net vNext early beta publish to IIS in windows server
How to configure an MVC6 app to work on IIS?
The
Tried
But it doesn't read from there
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
but in IIS using application settings I can dynamically set config values and connection strings while using.net 4.5.*. So is there any way to do like that in ,net 8
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
More like I can't understand the docs. Sorry
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
I mean after publishing I get web.config and appsettings file
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
how would you do in my situation where I need to set some config values but later need to change it but using IIS application settings tab
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
Ok so manually editing appsettings.json can trigger hot reload and the iis works with my new config values right?
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
for say in aws lambda I need to redeploy my function only when I need to change config value in appsettings. So is there any alternative in this case
But I want to set env vars in pool and let my webapi to get from there using Environment.GetEnvironmentVariable without IConfiguration. I tried setting it in pool en vars but still not working unless i set it in system level
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
Im REALLY REALLY SORRY
Worked on Legacy system for way too long and don't want my peers to be uncomfortable when I'm migrating .
Guess we all need to upgrade
I'm deeply grateful and Really SORRY for my legacy approach
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
But I need a config value in class library. How to get that
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
can I have some example because stackoverflow is mostly about JSONFIle on class Lib
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
appsettings.json:
src/Foo/FooOptions.cs:
src/Foo/FooServiceCollectionExtensions.cs:
Program.cs / Startup.cs:
Bar.cs:
I really need to study this