logo
down
shadow

Write appSettings in external file


Write appSettings in external file

By : user2949047
Date : November 16 2020, 06:23 AM
hop of those help? Finally, I have found a solution.
The solution is to declare the config file as this:
code :
<appSettings configSource="app.file.config">
<add key="var1" value="value 1" />
  <add key="var2" value="value 2" />
  <add key="var3" value="value 3" />
</appSettings>
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
AppSettingsSection myAppSettings = config.GetSection("appSettings")
myAppSettings.Settings["var1"].Value = "value 11";
config.Save(ConfigurationSaveMode.Modified);


Share : facebook icon twitter icon
Passing AppSettings to external javascript file the MVC way?

Passing AppSettings to external javascript file the MVC way?


By : Raj Arul
Date : March 29 2020, 07:55 AM
around this issue You could send them via a JsonResult?
In your JS, you'd have a request which sends a GET/POST request to a particular action (let's call it GetAppSetting(), and the corresponding value is returned in the response.
code :
public JsonResult GetAppSetting(string id)
{
  //You could check what's been requested here if you want to make sure you're only returning information that you may not wish to send.
  string appSetting = AppSettings[id];

  if(string.IsNullOrEmpty(appSetting) == false)
  {
    return Json(appSetting, JsonRequestBehavior.AllowGet);
  }

  //Handle non-existent settings here...
  throw new Exception("This setting does not exist");
}
public JsonResult GetAppSettings()
{
  var appSettings = new Dictionary<string, string>();
  appSettings.Add("myAppSetting1", AppSettings["myAppSetting1"]);
  appSettings.Add("myAppSetting2", AppSettings["myAppSetting2"]);
  appSettings.Add("myAppSetting3", AppSettings["myAppSetting3"]);

  return Json(appSettings, JsonRequestBehavior.AllowGet);
}
Encrypting AppSettings in file external to Web.Config

Encrypting AppSettings in file external to Web.Config


By : Ardiel
Date : March 29 2020, 07:55 AM
should help you out We do this all the time as we use external files for each of our environments.
First your appSettings element needs to look like this:
code :
<appSettings configSource="IndividualAppSettings.config" />
aspnet_regiis -pe "appSettings" -prov "{0}" -site {1} -app "/"
How to get external appSettings file name?

How to get external appSettings file name?


By : Катя Орехова
Date : March 29 2020, 07:55 AM
this will help I have ASP.NET server app which has in web.config : , This should do the trick:
code :
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings");
String externalFilename = appSettingSection.File;
How to read XML appSettings from external file?

How to read XML appSettings from external file?


By : TeeNik Smith
Date : March 29 2020, 07:55 AM
Hope this helps
in a .config file outside of my solution (in the same level as the solution folder).
External AppSettings File NOT merging with web.config

External AppSettings File NOT merging with web.config


By : nare
Date : March 29 2020, 07:55 AM
hope this fix your issue I just had the same issue (configs not merging as expected), but after explicitly deleting the /bin and /obj directories from the solution-folder and performing a rebuild, everything worked as expected again, so I would suggest you try that and see how it works...
PS: Also make sure you set the file properties of the external config to 'Copy Always'. Otherwise it won't exist in the bin-directory where your running application lives.
Related Posts Related Posts :
  • Why does C# also not allow empty conditions in while loops?
  • Unable to get a block of code into my regex match groups
  • What is difference between dbcontext.Add and dbcontext.AddObject
  • How do I update the file version number of C# DLL without recompiling?
  • Value for html control always null
  • HttpClient hangs when timeout is setting (Windows Phone)
  • Handle Multiple Form tag in asp.net page?
  • create word document with html content in c#
  • Confusion about Find And Replace
  • Format sms messages in Clickatell
  • Automated Function Overload
  • String to date in MS Access SQL statement gives type mismatch error
  • ShowDialog exiting on certain events
  • Is there a try Convert.ToInt32... avoiding exceptions
  • How to move wpf application into minimize tray at Window Start-up C#?
  • How to change display format of long variable?
  • How to use Addfields in MongoDB C# Aggregation Pipeline
  • MsTest TestCleanup method not called when an unhandled exception is thrown
  • missing last data when exporting gridview to excel
  • How to add array of objects to List in c#
  • Lambda Expression to order (sort) my list collection
  • Library for displaying music notation
  • How to compare two dictionaries in c# and get the output as True and False after validation
  • specify fields to be serialized with JSON
  • How do you obtain the content of a specific node using XmlDocument in C#?
  • How to ignore the first line in a csv file when you read the csv file in C#
  • c# - Problem calling public void from class
  • How to tell a class which objects it should create? Type vs. object confusion :(
  • Save CheckBox state to xml
  • WIX CAQuietExec NETSH Command Fails
  • Issues sending http put request every 60 seconds to RoR app
  • ConfigurationManager.ConnectionStrings.ConnectionString Issue
  • Real size WPF controls for printing
  • How to cancel properly?
  • C# String multiplication error
  • Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs
  • Regex pattern for single backslash
  • TextBox: insert spaces for credit card number?
  • C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe
  • Debug a Windows Service with WCF library
  • Open a file from an external assembly?
  • Servicestack RegistrationFeature Unable to bind request
  • Index was outside the bounds of the array confusion
  • Error in Xml to List code. The ':' character, hexadecimal value 0x3A, cannot be included in a name
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • How to discover that appsettings changed in C#?
  • Check what needs full trust
  • What is the execution order of an MVC Razor view/layout
  • Table designer (Entity Framework) is too resource intense
  • How to clean up an exception string so it can be displayed via Javascript Alert?
  • Configuring Amazon SES Feedback Notifications via Amazon SNS in ASP.NET MVC (C#)
  • C# api responce and request
  • Dynamodb putitem function not working properly
  • theme in windows phone(light or dark) using c#
  • Backup attached database file(.mdf) using c# and SQL Server
  • What is 'TextFile' and where it is uses in WPF project
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org