appsettings

Using appsettings in the DAL layer

◇◆丶佛笑我妖孽 提交于 2019-12-03 16:08:47
I have a winforms application in which some of the data is stored in XML files. The location where these XML files should be stored can be configured by the user, and is stored in the AppSettings. All my layers are separate assemblies. Can I access my settings from my DAL assembly, or should I pass this as an argument through all my layers? When I try to read the settings from my DAL layer, I encounter another problem Configuration config = ConfigurationManager.OpenExeConfiguration( System.Reflection.Assembly.GetEntryAssembly().Location); string dataStorageLocation = config.AppSettings[

Unable to set my connectionstring in NLog

时间秒杀一切 提交于 2019-12-03 11:49:39
The NLog.config file does not set the connection string. <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Warn" internalLogFile="c:\temp\internal-nlog.txt"> <!-- Load the ASP.NET Core plugin --> <extensions> <add assembly="NLog.Web.AspNetCore" /> </extensions> <variable name="SirNLogDb" value="data source=SQL_MULALLEY;initial catalog=LogFiles;User ID=xxx;Password=yyy;"> </variable> <!-- providerName="System.Data.SqlClient"--> <!-- the targets to write to -

How to read appsettings.json in my _layout.chtml

点点圈 提交于 2019-12-03 11:13:10
问题 I cannot seem to figure out how to read values from the appsettings.json in my _Layout.chtml file. Is it not just available, something like this? @Configuration["ApplicationInsights:InstrumentationKey"] I created a new MVC project using razor pages. fyi, i'm an mvc newbee - code samples help a lot. 回答1: In .net core mvc you can inject the configuration by adding the following two lines at the top of your view: @using Microsoft.Extensions.Configuration @inject IConfiguration Configuration You

Storing values in the web.config - appSettings or configSection - which is more efficient?

本秂侑毒 提交于 2019-12-03 09:22:50
问题 I'm writing a page that can use a couple of different themes, and I'm going to store some information about each theme in the web.config. Is it more efficient to create a new sectionGroup and store everything together, or just put everything in appSettings? configSection solution <configSections> <sectionGroup name="SchedulerPage"> <section name="Providers" type="System.Configuration.NameValueSectionHandler"/> <section name="Themes" type="System.Configuration.NameValueSectionHandler"/> <

Error parsing AppSettings value with a query string

老子叫甜甜 提交于 2019-12-03 05:03:50
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? abatishchev Replace & with & (escape it): <add key="ExternalSystemUrl" value="http://domain.com/page.aspx?id={0}&action=eat&object=bacon" /> That's the common requirement for

How to read appsettings.json in my _layout.chtml

十年热恋 提交于 2019-12-03 01:45:40
I cannot seem to figure out how to read values from the appsettings.json in my _Layout.chtml file. Is it not just available, something like this? @Configuration["ApplicationInsights:InstrumentationKey"] I created a new MVC project using razor pages. fyi, i'm an mvc newbee - code samples help a lot. In .net core mvc you can inject the configuration by adding the following two lines at the top of your view: @using Microsoft.Extensions.Configuration @inject IConfiguration Configuration You can then access the value like this: @Configuration.GetSection("ApplicationInsights")["InstrumentationKey"]

Storing values in the web.config - appSettings or configSection - which is more efficient?

随声附和 提交于 2019-12-02 23:42:40
I'm writing a page that can use a couple of different themes, and I'm going to store some information about each theme in the web.config. Is it more efficient to create a new sectionGroup and store everything together, or just put everything in appSettings? configSection solution <configSections> <sectionGroup name="SchedulerPage"> <section name="Providers" type="System.Configuration.NameValueSectionHandler"/> <section name="Themes" type="System.Configuration.NameValueSectionHandler"/> </sectionGroup> </configSections> <SchedulerPage> <Themes> <add key="PI" value="PISchedulerForm"/> <add key=

Adding settings class to a UWP app

被刻印的时光 ゝ 提交于 2019-12-02 19:54:12
I'm developing a Universal Windows Platform app but there is no Settings template in Visual Studio. How can I implement an easy, strongly typed and observable class that stores my settings in LocalSettings or RoamingSettings? Create a new class inheriting from ObservableSettings. Call to the base class constructor indicating if you want to store the settings in LocalSettings or in RoamingSettings . Add all your properties calling the base class members Set and Get in the getter and in the setter. No need to pass the name of the property or use nameof() operator! Optionally you can set a

c# Initialize Appsettings from database

风流意气都作罢 提交于 2019-12-02 04:45:45
We have an already existing console application which currently uses File based AppSettings. So my app.config points to my actual appsettings file : <appSettings configSource="Configs\StaticAppSettings.config"/> And in the entire code we are accessing the configuration as such : var value = ConfigurationManager.AppSettings["SomeKeyName"]; Going forward we want the appSettings to be in the Database.So if we want to keep the same codebase and just modify how we initialize the appsettings, is that going to be the right approach ? We are planning to do something like this as initialization of

c# Initialize Appsettings from database

倖福魔咒の 提交于 2019-12-02 03:46:39
问题 We have an already existing console application which currently uses File based AppSettings. So my app.config points to my actual appsettings file : <appSettings configSource="Configs\StaticAppSettings.config"/> And in the entire code we are accessing the configuration as such : var value = ConfigurationManager.AppSettings["SomeKeyName"]; Going forward we want the appSettings to be in the Database.So if we want to keep the same codebase and just modify how we initialize the appsettings, is