You can use web.config to set different variables. Use a separate web.config for each environment. For example. web.release and web.debug. The same can be used. Separate files for each environment
If you are using Octopus deployment. Use can also be set in variable octopuses.
<appSettings> <add key="MyVariable1" value="False" /> <add key="MyName" value="akshay bheda" /> </appSetting>
Now you can easily access this variable and its values ββfrom your C # code:
string myVariable = System.Configuration.ConfigurationSettings.AppSettings["MyName"];
Now instead of writing url you can use this line.
<a href="<%= ConfigurationManager.AppSettings["someKey"] %>">
If you do not want to use Octopus Deployment, you can follow these steps.
1.) Create a new configuration from Configuration Manager. It is located in the Build menu.
and create a new configuration, for example, for example. production and select "Copy settings from Debug" or any other existing web.config so you don't have to write again.
2.) After creating a new configuration, right-click on Web.config and select Add Configuration Configuration .
after that you will find the new web.config configuration.
Make changes to the appSettings section in each of your configurations, and when you start the project, select the assembly configuration.
From this configuration, select configuration settings from the appSettings section.
Akshay bheda
source share