I have declared the QA server path statically in the constant.cs entity framework core, but I need to add dynamically so based environment it should work
example : In mail template
I have one button in that it is linked to QA server appliaction but it should change dynamically ,what configuration I need to do
Rijwan AnsariPosted Mar 22, 2023, 2:26 PM
Hi,
You can use below code.
Vishal JoshiPosted Mar 22, 2023, 12:29 PM
Hello
You can use HttpContext class to get the server path and it will automatically work based on the server.
Thanks
Tuhin PaulPosted Mar 22, 2023, 1:28 AM
you can also inject IOptions wherever you need to access the configuration settings
Tuhin PaulPosted Mar 22, 2023, 1:27 AM
You can define the configuration settings in the appsettings.json file, like this:
and in your Startup.cs file, add the following code to read the configuration settings:
Here, AppSettings is a class that defines the configuration settings,
Tuhin PaulPosted Mar 22, 2023, 1:25 AM
To make the server path configurable based on the environment, you can use the built-in configuration system in .NET Core.