configurationmanager

Can't read Web.config with ConfigurationManager.AppSettings

心不动则不痛 提交于 2019-12-10 21:19:57
问题 I have build a WCF service that uses Web.config to get some appSettings. In visual studio it works great but when I publish and instal the service it suddenly gets its appSettings from App.config and not from Web.config. I know this because I loop through appSettings and printed the result to the console with this code: foreach (string key in ConfigurationManager.AppSettings.AllKeys) { Console.WriteLine("Name: {0} Value: {1}", key, ConfigurationManager.AppSettings[key]); } My configs look

Is appsettings.json protected by IIS?

限于喜欢 提交于 2019-12-10 17:13:16
问题 In legacy ASP.NET applications, *.config files cannot be downloaded by navigating to the URL. But the new convention is to use appsettings.json . Now, if I have a ASP.NET Core website called contoso.com and it's served by IIS from a directory called C:\inetpub\websites\contoso.com , and there is a file located at C:\inetpub\websites\contoso.com\appsettings.json ... Is IIS smart enough to know not to serve this file over HTTP if someone navigates to https://contoso.com/appsettings.json? 回答1:

How to read basicHttpBinding defined in app.config file

瘦欲@ 提交于 2019-12-10 15:28:35
问题 I'm trying to figure out how to read how to read basicHttpBinding section defined in app.config file. I attempted to do it like I did the endpoint address but it does not work. Here is how I did my endpoint address: private EndpointAddress EndPointAddy { get { var config = ConfigurationManager.GetSection("system.serviceModel/Client") as ServiceModelSectionGroup; foreach (ChannelEndpointElement endpoint in config.Client.Endpoints) { Uri address = endpoint.Address; if (address != null) { return

Reading settings from App.Config

孤者浪人 提交于 2019-12-10 11:36:22
问题 Config file. How should I read values of username and password in C# using System.Configuration.ConfigurationManager class? I have tried several stuff but to no avail. The app.config is given below. <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="Fulfillment.Properties.Settings" type="System.Configuration

How to make ConfigurationManager read a config file other than app.config?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 01:52:21
问题 I need to parse a config file that is situated in another project. I know that ConfigurationManager reads the app.config file by default, but how to make it read that particular config file? 回答1: // Create a filemap refering the config file. ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = configFilePath; // Retrieve the config file. Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

Visual Studio will not give me the platform option of 64 bit in configuration manager..?

社会主义新天地 提交于 2019-12-09 00:34:22
问题 I am currently trying to build a project for a 64 bit computer, but the configuration manager doesn't list 64 bit as an option. It gives me Win32, but no x64 (under "Platform"). I am using Visual Studio 2010 C++ Express. It works on my other computer, but not this one. Most everything I have read has been saying to go up to the "Active Solution platform" drop down, and add 'x64' to it. I have tried that, but it still only lists Win32. 回答1: Select the Configuration Manager as given by the

Using .NET ConfigurationManager to read settings from a string instead of an app.config file

余生颓废 提交于 2019-12-08 00:48:08
问题 We are running multiple instances of our service (implemented as a .exe file) on different machines in our data center. However, we would like to store configuration parameters for this .exe file in a central location (as opposed to being in the .exe.config per machine). To do this, we are planning to move the content of the .exe.config files to an attribute in a central repository (Active Directory or SQL) and make the .exe's running on all machines read from this repository. I would like

Getting a StringCollection out of AppSettings through the configuration manager

大憨熊 提交于 2019-12-07 06:13:53
问题 I am accessing my assembly's configuration like this: ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = Assembly.GetExecutingAssembly().Location + ".config"; Configuration conf = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); AppSettingsSection appSettings = conf.AppSettings; My .config file contains a section like this <configSections> <sectionGroup name="applicationSettings" type="System.Configuration

ConfigurationManager Save() wants to create a tmp-File

落爺英雄遲暮 提交于 2019-12-07 05:23:54
问题 I am having problems with a application that wants to write to the .exe.config. See following code: using System; using System.Configuration; using System.IO; namespace ConfigurationManagerError { class Program { static void Main(string[] args) { try { // set Config-File to persistent folder ExeConfigurationFileMap exeMap = new ExeConfigurationFileMap(); exeMap.ExeConfigFilename = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ConfigError\

How to open a SectionGroup in an ASP.NET web application?

对着背影说爱祢 提交于 2019-12-06 19:35:21
问题 I have a small ASP.NET web application hosted in an integration test (executing within NUnit). My product code can usually find configuration data from the web.config or app.config file, but for some reason when hosting ASP.NET I seem to get an ArgumentException when executing the first of these commands: var configuration = ConfigurationManager.OpenExeConfiguration(null); return configuration.GetSectionGroup(SectionGroupName); exePath must be specified when not running inside a stand alone