Questions tagged [webconfigurationmanager]

41 questions
112
votes
4 answers

What's the difference between the WebConfigurationManager and the ConfigurationManager?

What's the difference between the WebConfigurationManager and the ConfigurationManager? When should I use one over the other? UPDATED I just looked at the WebConfigurationManager, and for some reason, you can't access the connection strings as you…
John B
  • 20,062
  • 35
  • 120
  • 170
37
votes
5 answers

How to OpenWebConfiguration with physical path?

I have a win form that creates a site in IIS7. One function needs to open the web.config file and make a few updates. (connection string, smtp, impersonation) However I do not have the virtual path, just the physical path. Is there any way I can…
aron
  • 2,856
  • 11
  • 49
  • 79
12
votes
2 answers

Differences in behavior between System.Web.Configuration.WebConfigurationManager and System.Configuration.ConfigurationManager

I had some trouble on a test server with an ASP.NET website. I goofed, and had the home directory of the Default Web Site pointed to the wrong place. When I tried: ConfigurationManager.ConnectionStrings["connectionString"]; it returned null,…
11
votes
3 answers

Loading a ConfigurationSection with a required child ConfigurationElement with .Net configuration framework

I have a console application that is trying to load a CustomConfigurationSection from a web.config file. The custom configuration section has a custom configuration element that is required. This means that when I load the config section, I expect…
8
votes
2 answers

Can someone provide a quick App.config/Web.config tutorial?

I've used these two configuration files many times before, but I've never taken the time to fully understand how they really work. As most people do, I understand the basics in how to call WebConfigurationManager.AppSettings["key"] to get config…
3
votes
3 answers

Read appSettings section from Web.config file using WebConfigurationManager

I'm developing a WinForm application with C# and .NET Framework 4.7. I want to open a Web.config file, read its appSetting section and modify it. To open it, I use this: System.Configuration.Configuration config =…
VansFannel
  • 45,055
  • 107
  • 359
  • 626
2
votes
1 answer

.NET ConfigurationElementCollection.Add method does not add item to collection

I have a custom configuration section running under ASP.NET 4.0 that I would like to save changes to. The classes involved are: QueueConfiguration: a ConfigurationElement QueueCollection Queues // a list of queues to be…
Eric Patrick
  • 2,097
  • 2
  • 20
  • 31
2
votes
0 answers

Application start called each time page is refreshed when config is changed in application_start

I want to update web.config just once when application is started. For this I thought I can use application_start method in Global.asax. While application_start is called only once normally when the first request is made to website, it is being…
tubakaya
  • 457
  • 4
  • 15
2
votes
1 answer

Web.config anonymousIdentification cookieName via Code in Medium Trust?

Is there an easy way to read the cookieName from the web.config for the anonymousIdentification section while working in Medium Trust? What I'm trying to do is prevent the creation of thousands of Anonymous users because either: people have cookies…
Sam
  • 9,933
  • 12
  • 68
  • 104
2
votes
3 answers

Trying to open a section from the web.config spans a ConfigurationErrorsException: The entry KEY has already been added

I'm trying to fetch some settings from my membership provider in my asp.net application (so that I don't have to duplicate the information in the appSettings section) but I am getting the following…
Pablo
  • 2,054
  • 8
  • 30
  • 56
1
vote
2 answers

Manipulating web.config in memory

I have a web.config file open in a textbox and would like to manipulate it. For example, allowing the user to change the DBConn string or something. At the stage of trying to change this, the config text may, or may not exist as a physical file. …
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
1
vote
0 answers

Multiple Web Config Files

So, I have an application that needs multiple Webconfigs. I seperated each Web form in its own folder and put a web config file. How do I make sure that Login Webform only uses the LoginWeb.Config? This is my root Web Config and that is what it's…
Airizzo
  • 165
  • 1
  • 12
1
vote
1 answer

ASP.NET: HttpRuntime.Cache getting flushed when saving WebConfigurationManager -- Is this a bug?

Recently, I've been experimenting with caching objects with HttpRuntime.Cache and I was generally under the impression that if I "added" something to the cache like this: HttpRuntime.Cache.Insert("Test", "This is a test!", null, …
Pretzel
  • 8,141
  • 16
  • 59
  • 84
1
vote
2 answers

How to retrieve on which site the web application is currently running?

I am currently running a WCF service on an AppFabric server and my application needs to load a the web.config file dynamically to retrieve custom configuration sections. On my development machine I can just load the configuration like…
Ucodia
  • 7,410
  • 11
  • 47
  • 81
1
vote
1 answer

Can't programmatically access WebConfigurationManager in VS 2012

In my VS 2012 project, I have a reference to System.Web. If I browse System.Web in Object Brower, it contains System.Web.Configuration.WebConfigurationManager; but in my code, System.Web only shows me AspNetHostingPermission,…
1
2 3