appsettings

Can't read from appSettings

孤街醉人 提交于 2019-12-11 05:47:38
问题 I have a test project with a web.config file in the test project. I keep getting null when I try to read a value from the appSettings section of the web.config. I have a reference to System.configuration and a using statement using System.Configuration; <appSettings> <add key="SatisfactionSurveyLink" value="Link"/> </appSettings> [TestMethod()] public void TestReadFromAppSettings() { String surveyLink = ConfigurationManager.AppSettings["SatisfactionSurveyLink"]; Assert.IsNotNull(surveyLink);

AppSettings in markup issue

余生长醉 提交于 2019-12-11 02:12:12
问题 I am trying to put this in my markup: <script type="text/javascript" src="<%$ AppSettings:proxyScriptUrl %>"></script> But for some reason this is not accepted. What am I doing wrong here? The requirement is that I do not use a helper method but that the expressionbuilder is used in the markup. 回答1: According to the documentation, that's not allowed: If you want to use an expression as a static value on your page or control, you use an expression as part of an ASP.NET server control. A

Changes in App.config do not reflect after restarting the application

家住魔仙堡 提交于 2019-12-10 15:58:49
问题 I am using an app.config file to store the dynamic parameters of my application. The problem is, when I change a value in app.config file, and start the application, it doesn't load the new value from config file. Seems like the values in app.config file are being read and embedded in exe file only at compile time! This is how I read the config file: public class Helper { static Helper() { Foo = ConfigurationManager.AppSettings["Foo"]; } public static string Foo { get; set; } } Am I missing

Save File to MyDocuments + App Folder

空扰寡人 提交于 2019-12-09 16:45:32
问题 I am trying to save my .NET application settings file to the user's %MyDocument%\MyApplication folder, but I don't know how to check for an existing folder\file, and create or append the folder\file on save. I don't want to open a saveFileDialog because I need the file to be in the same place on all user computers. This is what I have so far, but it isn't working. Any help would be appreciated: var saveSettings = settingsList.text; //assign settings to a variable saveSettings = Regex.Replace

Auto-generate a strongly-typed AppSettings class

血红的双手。 提交于 2019-12-09 06:25:07
问题 Here's the question first: Is this possible? I'm taking my inspiration from Joe Wrobel's work (a redux of the forgotten Codeplex project). Here, you do your work on creating your profile for the provider, and it does the legwork of creating the strong typing for it, effectively creating a facade for the Profile class. And now the back story! I really don't like magic strings. They're pretty bad and can cause some serious issues when it comes to updating your application. Having worked in

Configure Column Options for Serilog Sinks MsSqlServer in AppSettings.json

♀尐吖头ヾ 提交于 2019-12-08 01:50:19
问题 I'm trying to determine if it's possible to configure the column options for serilog sink mssqlserver in the appsettings.json file for an ASP.Net Core 2 project. I create and configure the logger in the Program.cs file. public static IConfiguration Configuration { get; } = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE

Code required to use foreach on my own custom appSettings

心不动则不痛 提交于 2019-12-07 18:04:38
问题 I've searched the site and haven't found exactly what I'm looking for. Close, but no cigar. Basically I want to have a config section like this: <configSections> <section name="PhoneNotificationsSection" type="Alerts.PhoneAlertConfigSection,Alerts,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"/> </configSections> <PhoneNotificationsSection> <phones> <add phone="MyMobile" value="1234567890@vtext.com" /> <add phone="OtherMobile" value="1234567890@txt.att.com" /> </phones> <

Optional appsettings.local.json in (new format) visual studio project

独自空忆成欢 提交于 2019-12-07 02:40:05
问题 My app uses appsettings.json for some settings. If appsettings.local.json is present, that should override appsettings.json for whatever settings it contains. So far, no problem. But I use git for version control. Obviously, I don't want other users pulling down my local settings. So I git ignore appsettings.json. Furthermore, there are a lot of projects in the solution. They share the same settings. So there is an appsettings.json at the solution level, and all the projects include it as a

Removing inherited ASP.NET Core appsettings

£可爱£侵袭症+ 提交于 2019-12-07 00:26:38
问题 I have the following setup in my Startup: var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true); .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true) appsettings.json: { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } I know I can override the effective settings for a given environment by adding a matching JSON structure with different values and omitting those I want to

Access section 'applicationSettings' (not 'appSettings') in config file from setup

孤人 提交于 2019-12-06 14:13:50
I am in the process of creating a setup for a web application we build. No I have a configuration file, which looks something like like this, which contains a section 'appSettings', and a section 'applicationSettings': <configuration> <appSettings> <add key="Password" value="dummy"/> <add key="Username" value="dummy"/> <add key="DB" value="dummy"/> <add key="DBServer" value="dummy"/> <add key="LogStoredProcedure" value="dummy"/> <add key="ErrorStoredProcedure" value="dummy"/> <add key="ErrorFileName" value="dummy"/> <add key="EncryptionKey" value="dummy"/> </appSettings> <applicationSettings>