appsettings

Why is not injected last version of configuration (appsettings.json)?

馋奶兔 提交于 2020-01-16 08:43:24
问题 I am trying to edit appsettings.json in runtime. I found great solution how to update this file: https://stackoverflow.com/a/45986656/9684060 I did everything according to answer above: 1) Added MySettings to DI container ( MySettings are added via AddTransient ) services.ConfigureWritable(Configuration.GetSection(nameof(MySettings))); 2) Constructor injection private readonly IWritableOptions<MySettings> _cfg; public MyController(IWritableOptions<MySettings> cfg) { _cfg = cfg; } Then I use

Get access to AppSettings from custom Installer during uninstall (BeforeUninstall)

浪子不回头ぞ 提交于 2020-01-13 14:03:50
问题 I have a VS solution with following structure: Library project (.dll) Application using the #1 library project I have app.config defined in the application (#2) which defines a SaveLogsToDirectory path in appSettings. This value is eventually used by the library project to save the logs generated. Simple use of api System.Configuration.ConfigurationManager.AppSettings["SaveLogsToDirectory"] in the library fetches the value from app.config. Library project has a custom System.Configuration

How to update appSettings in a WPF app?

牧云@^-^@ 提交于 2020-01-12 14:32:11
问题 Greetings to all! This is my first question here on stackoverflow. I have a WPF application that I am writing for the fellow developers in my department, and there are a couple of settings that I need to check for at startup and update if they are not set (one is the location of an executable on the users computer, we all have it, just not in the same place). So when my app starts up for the first time, I need to pop a filechooser to have them select the location. What I need to do is write

React and AppSettings in Azure

一曲冷凌霜 提交于 2020-01-05 04:19:06
问题 My goal is to retrieve some environnement keys from Azure Application settings like api_url. My build factory is the following : webpack for the tsx to minified js build and release with VSTS deploy on Azure Web App There is no node.js running on Azure Web App, it is just a static server that serve index.html, bundle.js and assets. I have tried this different method : Below this example, if I load system vars, I will be able to retrieve this key/value. I have tried with dotenv-webpack and

How to add configuration values in AppSettings.json in Azure functions. Is there any structure for it?

夙愿已清 提交于 2020-01-02 00:58:11
问题 What is the standard structure to add keys to appsettings.json ? Also, how to read those values in our run.csx ? Normally in app.config, we had ConfigurationManager.GetSettings["SettingName"]; Is there any similar implementation in Azure Function? 回答1: As stated here These settings can also be read in your code as environment variables. In C#, use System.Environment.GetEnvironmentVariable or ConfigurationManager.AppSettings . In JavaScript, use process.env . Settings specified as a system

Background App Refresh checking, enabling and disabling programmatically for whole device and for each particular application in iOS 7

混江龙づ霸主 提交于 2020-01-01 16:58:49
问题 We can check Background App Refresh for whole device and for each particular application in iOS 7 manually from settings. Is there any way to do it programmatically in iOS 7? 回答1: The short answer is no you can't check to see what every app's Background Refresh setting is due to application sandboxing. An application may how ever check to see if the user has modified the Background Refresh setting for itself. Detecting user settings for Background App Refresh in iOS 7 来源: https:/

Background App Refresh checking, enabling and disabling programmatically for whole device and for each particular application in iOS 7

自闭症网瘾萝莉.ら 提交于 2020-01-01 16:58:17
问题 We can check Background App Refresh for whole device and for each particular application in iOS 7 manually from settings. Is there any way to do it programmatically in iOS 7? 回答1: The short answer is no you can't check to see what every app's Background Refresh setting is due to application sandboxing. An application may how ever check to see if the user has modified the Background Refresh setting for itself. Detecting user settings for Background App Refresh in iOS 7 来源: https:/

Error parsing AppSettings value with a query string

霸气de小男生 提交于 2020-01-01 01:35:13
问题 In my AppSettings in web.config, I have something like this: <appSettings> <add key="ExternalSystemUrl" value="http://domain.com/page.aspx?id={0}&action=eat&object=bacon" /> </appSettings> However, it seems that when an ampersand ( & ) is included in an AppSettings value, ASP.NET throws the following error: An error occurred while parsing EntityName Why does this happen, and how can I include URLs like this in App.config? 回答1: Replace & with & (escape it): <add key="ExternalSystemUrl" value=

How to reference another value within the same appsettings.json file?

十年热恋 提交于 2019-12-31 04:20:08
问题 I need database connection string in two places in appsettings.json. Is it possible to introduce common variable or json-path related references into json file to avoid potencial problems? It would be lovely to have it without touching c# code. { ... "ConnectionStrings": { "Default": "Host=localhost;Database=db;Port=5432;Username=postgres;Password=postgres" }, "Nlog": { "targets": { "database": { "type": "Database", "dbProvider": "Npgsql.NpgsqlConnection, Npgsql", "connectionString": "Host

ConfigurationSettings.AppSettings is obsolete, warning

落爺英雄遲暮 提交于 2019-12-30 04:56:27
问题 var values = new NameValueCollection { { "key", ConfigurationSettings.AppSettings["API-Key"].ToString() }, { "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) } }; What's the new way to use the app.config file? 回答1: The ConfigurationManager class in System.Configuration : ConfigurationManager.AppSettings ConfigurationManager.ConnectionStrings So your code would change to: var values = new NameValueCollection { { "key", ConfigurationManager.AppSettings["API-Key"] }, { "image