appsettings

Configure Column Options for Serilog Sinks MsSqlServer in AppSettings.json

浪尽此生 提交于 2019-12-06 04:50:08
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_ENVIRONMENT") ?? "Production"}.json", optional: true) .AddEnvironmentVariables() .Build(); public static

Values from linked appsettings.json file in dotnet core cannot be read

做~自己de王妃 提交于 2019-12-06 03:23:44
In an aspnetcore 2.0 project I'm trying to setup a single, shared appsettings.json file throughout my web application and several of my xunit test projects. First off, everything works fine when I add the appsettings.json "regularly" to my projects individually. However, when I attempt to add a single reference/linked file from a different path, the values aren't read out during runtime. To set this up, for each project I add the linked file to the .csproj: <ItemGroup> <Content Include="..\Shared\appsettings.json"> <Link>appsettings.json</Link> <CopyToOutputDirectory>Always<

Get appsettings.json values in service .net core

蹲街弑〆低调 提交于 2019-12-05 21:40:53
I have appsettings.json file where I want to declare paths to files. "Paths": { "file": "C:/file.pdf" } I want to access this value in my service, I try it to do like this: public class ValueService: IValueService { IConfiguration Configuration { get; set; } public MapsService(IConfiguration configuration) { this.Configuration = configuration; } public string generateFile() { var path = Configuration["Paths:file"] ; } } however I get null values for var path Startup.cs file has appsettings.json declared as it takes connection string from there. Is it possible to access these values outside

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

时间秒杀一切 提交于 2019-12-05 08:02:52
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 link. Still fine, except for one thing. In order to be usable, I have to copy appsettings.local.json

Removing inherited ASP.NET Core appsettings

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 05:44:35
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 inherit, e.g. appsettings.Development.json: { "Logging": { "LogLevel": { "Default": "Warning" } But

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

强颜欢笑 提交于 2019-12-05 01:59:27
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? 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 environment variable take precedence over values in the local.settings.json file. In Azure Functions 2.x, you

Change in AppSettings needs restart my Application how can I avoid?

久未见 提交于 2019-12-04 11:18:33
问题 I'm using C# .NET 2.0 Windows Application. and I'm using app.config for my Application Settings. but change in AppSettings doesn't reflected runtime, it Needs Application to be restarted. How can I avoid it. Here is my code snippet I used to read and write the Application Settings. I'm reading the Setting like this string temp = ConfigurationManager.AppSettings.Get(key); I'm updating the value like this where node is the current configuration/appSettings Node node.Attributes["value"].Value =

wpf - Get values from App Config file

别说谁变了你拦得住时间么 提交于 2019-12-04 04:39:22
How to get values from App.Config. Code: <configuration> <appSettings> <add key="ShowRoomCode" value="1000"/> <add key="FolderPath" value="D:\\Images\\Book\\"/> </appSettings> </configuration> string imageFolderPath = ConfigurationManager.AppSettings["FolderPath"]; But it returns null value. Config file is in the Same project. If you expand the Properties section of Visual Studio and double click the settings section, you will be able to add custom settings which end up like so in the config file: <configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration

Save File to MyDocuments + App Folder

爱⌒轻易说出口 提交于 2019-12-04 04:04:04
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(saveSettings, @"\s+", "").Trim() + Environment.NewLine; //remove any extra spaces and add a carriage

How to update appSettings in a WPF app?

倖福魔咒の 提交于 2019-12-04 03:04:33
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 the location of that to the appSettings, but I just can't seem to get it, and I searched Google pretty