appsettings

ASP.NET Core appsettings.json update in code

纵饮孤独 提交于 2019-11-29 22:30:24
I am currently working on project using asp.net core v1.1, and in my appsettings.json I have: "AppSettings": { "AzureConnectionKey": "***", "AzureContainerName": "**", "NumberOfTicks": 621355968000000000, "NumberOfMiliseconds": 10000, "SelectedPvInstalationIds": [ 13, 137, 126, 121, 68, 29 ], "MaxPvPower": 160, "MaxWindPower": 5745.35 }, I also have class that I use to store them: public class AppSettings { public string AzureConnectionKey { get; set; } public string AzureContainerName { get; set; } public long NumberOfTicks { get; set; } public long NumberOfMiliseconds { get; set; } public

Value cannot be null. Parameter name: connectionString appsettings.json in starter

拟墨画扇 提交于 2019-11-29 13:12:14
I am trying to write my connection string in my appsettings.json file and bring it into my startup file but I keep getting a Value cannot be null. Parameter name: connectionString. I have been using various examples but can't seem to see this new setup with ASP.NET 1.0 Core startup class. Appsetting.json file: { "Data": { "DefaultConnection": { "ConnectionString": "Data Source=server;Initial Catalog=dbase;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } }

Inject App Settings using Windsor

淺唱寂寞╮ 提交于 2019-11-29 12:43:50
问题 How can I inject the value of an appSettings entry (from app.config or web.config) into a service using the Windsor container? If I wanted to inject the value of a Windsor property into a service, I would do something like this: <properties> <importantIntegerProperty>666</importantIntegerProperty> </properties> <component id="myComponent" service="MyApp.IService, MyApp" type="MyApp.Service, MyApp" > <parameters> <importantInteger>#{importantIntegerProperty}</importantInteger> </parameters> <

Access appsettings.json values in controller classes

淺唱寂寞╮ 提交于 2019-11-29 12:09:26
问题 Having trouble figuring out how to read appsettings.json values outside of the startup.cs. What I would like to do is, for instance, is in the _Layout.cshtml, add the site name from the config: For example: ViewData["SiteName"] = Configuration.GetValue<string>("SiteSettings:SiteName"); Or even better: public class GlobalVars { public static string SiteName => Configuration.GetValue<string>("SiteSettings:SiteName"); } Here's my code thus far: [appsettings.json] "SiteSettings": { "SiteName":

Form submit resulting in “InvalidDataException: Form value count limit 1024 exceeded.”

可紊 提交于 2019-11-29 10:48:56
问题 I have created an mvc site and I'm posting a large amount of json form data ( Content-Type:application/x-www-form-urlencoded ) back to the mvc controller. When I do this, I receive a 500 response that states: "InvalidDataException: Form value count limit 1024 exceeded." In previous versions of aspnet, you would add the following to the web.config to increase the limit: <appSettings> <add key="aspnet:MaxHttpCollectionKeys" value="5000" /> <add key="aspnet:MaxJsonDeserializerMembers" value=

How to use ConfigurationManager.AppSettings with a custom section?

感情迁移 提交于 2019-11-29 10:19:27
I need to get " http://example.com " from using App.config file. But at the moment I am using: string peopleXMLPath = ConfigurationManager.AppSettings["server"]; I cannot get the value. Could you point out what I am doing wrong? <?xml version="1.0" encoding="UTF-8"?> <configuration> <configSections> <section name="device" type="System.Configuration.SingleTagSectionHandler" /> <section name="server" type="System.Configuration.SingleTagSectionHandler" /> </configSections> <device id="1" description="petras room" location="" mall="" /> <server url="http://example.com" /> </configuration> Chris

How do you put environmental variables in web.config?

被刻印的时光 ゝ 提交于 2019-11-29 05:38:35
I am currently Following these tutorials , and I am wanting to call the clear text string from Azure's Application Settings for Web Apps. I am under the impression that environmental variables are used for non-config files . However, I am wanting to use the same methodology for web.config files. <connectionStrings configSource="/config/ConnectionStrings.config"> <add name="DefaultConnection" connectionString="@Environment.GetEnvironmentalVariable('SQLAZURECONNSTR_DefaultConnection')" providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings file="config\AppSettingsSecret.config

How can I set application settings at install time (via installer class)

£可爱£侵袭症+ 提交于 2019-11-29 04:38:00
I have a Visual Studio setup project that has an Installer class. In the installer class I set a setting as follows: MessageBox.Show(Properties.Settings.Default.MySetting); Properties.Settings.Default.MySetting = "Foo"; Properties.Settings.Default.Save(); MessageBox.Show(Properties.Settings.Default.MySetting); The problem is that even though I know that this code is being executed (I am doing other stuff), the setting is never set!! The message boxes do suggest that the value is being set, but when I go to the .config file the value is still blank! Anyone have any ideas why and/or a possible

how to change .NET user settings location

99封情书 提交于 2019-11-29 03:49:35
By default settings are stored at: C:\Documents and Settings\\Local Settings\Application Data\<Project Name> How can I change this path to application directory. I also don't want to have different files for different users. How make the settings global? I tried to change the scope of the settings to "application" but then I cannot change them at runtime. Using the default built-in behavior you can't! Q: Why is the path so obscure? Is there any way to change/customize it? A: The path construction algorithm has to meet certain rigorous requirements in terms of security, isolation and robustness

Azure Application Settings not overriding my appsettings.json file values

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 03:06:32
I have tried adding DefaultConnection from my appsettings.json file to Azure's Application Settings but Azure will not override the connection string. Any article or blog I can find states that all I should need to do is add the connection string name as it states in the appsettings.json file and Azure should do the rest (e.g. https://tehremo.wordpress.com/2016/10/07/override-connection-strings-app-settings-in-asp-net-core-and-azure-app-service/ ) however when the application is published it is using my local connection string. My Startup.cs file looks like the following: NOTE: I am publishing