Storing Configuration Data In .NET Than The Web/machine Config?
Jun 24, 2010
We have a large multi tenanted website which requires thousands of lines of web.config to support it. As the system grows we are finding it more and more difficult to manage this configuration file.The system currently in place uses XSLT to generate the config but this solution seems to involve a lot of duplicated code (we have 12 deployment environments).
I am leaning towards putting the configuration data in the db so we can be sure that it's deployed with the application and that our release notes don't require the IT guys messing around with XML
What it best location to store various configuration settings of a web site modules. Creating class (that inherit ConfigurationSection) that map the settings in web.config file?Or creating some DAL and BLL clases that work with database?
I have connection strings info in web.config. I thought that if this were the case, machine.config would be ignored. But, everytime the connection string in web.con is different than the connection string in maching.con, I get error. The connection name 'aspnetdbConnectionString' was not found in the applications configuration or the connection string is empty. Is there something I can check or change to get the app to ignore the machine.config when web.config connection string is listed.
We have a problem regarding decrypting the web.config... We encrypted the web.config in computer A. but we need it to decrypt it in computer B.
we got an error
"Failed to decrypt using provider 'DataProtectionConfigurationProvider'. Error ssage from the provider: Key not valid for use in specified state. (Exception om HRESULT: 0x8009000B) (D:WCFSearchweb.config line 17)
Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B) Failed!"
we also tried the RSAProtectedConfigurationProvider and we're not able decrypt also...
I search google and found this unfortunately we can't decrpyt it... How do i include the key? do i need to copy and paste it?
I am loading the config file programaticality so that i can edit it but ive hit a hitch in that when i debug it through VS i get the following error:
An error occurred loading a configuration file: Failed to map the path '/'.
My code is:
I use it in other sections of my site and know that it works as intended when it is deployed to my webhost. I am having issues with another section where I use it so I want to step through it to debug, what do I change this "~" to, to correctly reference the config when I am debuging locally.
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
I just installed VS2010 and opened the root machine.config and web.config files for review and I found some errors. In machine.config, the following line has errors in both entries for <Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior>. When I hover the cursor over them I get a tooltip text which displays: "The element 'endpointBehaviors' has invalid child element 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior'. List of possible elements expected: '...(list of options here)...'. The same problem happens for the second appereance in tag <serviceBehaviors>.
In web.config, there is a tag called <protocols> that has an error with a tooltip text that says "The element 'system.web' has invalid child element 'protocols'. List of possible elements expected: '...(list of options here)...'.
I made a change in my machine.config for a 1.1 application and then later I upgraded the application to .Net Framework 3.0/3.5. Will that configuration change still apply or do I have to make that change in my local web.config for the 2.0 machine.config/web.config?
Using C#, is there are way to differentiate between ConnectionStrings in the machine.config and the web.config? I would like to iterate over the collection in the web.config but not those from the machine.config. ASP.NET 3.5, C#
It is known that we use web.config file to override the setting of machine.config file.
a) how come machine.config file knows that only changes made in web.config file are to be overwritten. I mean to say, if I use some other name for the config file say xyz.config, will it be able to work?
b) How does machine.config file know about web.config? Is there any link mentioned inside the machine.config file for that?
I have a simple web app that queries a server based database. I have tested with both a simple MySQL table and Access tables. The problem is the same whatever 'backend database' that I use. When I run my web application under the VS 2008 debuger then all works fine. No problems with the code. I then publish my web app to either my local IIS or to a different PC's IIS on my network. I then get 'intermittnet' problems reading the data tables. The connection strings are fine. I get a connection. It is when I try and fill the tables that I get errors. The web app just seems to 'hang'.
If I publish to a different IIS on my network (on a different server) the I get the same problems. If I reboot the IIS machine then I seem to be able to get to my data for a while before the IIS seems to 'lock up' and I can't read data anymore. Is this an IIS/authentication/resource issue?
There are a bunch of hardcoded strings in a ASP.NET application.
eg. string constSetting = "XYZ";
There are a LOT of them. Is there a tool/plugin for Visual Studio 2008 to refactor it in such a way that the constant string goes into web.config and the above line gets replaced by the retrieved string from web.config app settings?
I would like to store a collection of strings in the web.config. This collection would vary in size over time. I would like to be able to pull all of the strings in the collection into an array or collection in code. (.Net 4, asp.net) i.e.
I could use appsettings with the strings all in one value but I would like to seperate it out for organizational reasons. Not using the key/value pair complicates things a bit. I am now getting a message that states "you can't have duplicate elements in a section"
I would like to add this section to my machine.config in exactly the same way many articles and microsoft are suggesting:
<configuration> <system.net> <connectionManagement> <add name = [URL]/> <add name = "*" maxconnection = "2" /> </connectionManagement> </system.net> </configuration>
[URL] As soon as I do it though, I get this exception when trying to hit a page hosted on the IIS on the same machine: Parser Error Message: Unrecognized configuration section system.net. Source Error:
Line 9: settings that differ from their defaults. Line 10: --><configuration> Line 11: <system.net> Line 12: <connectionManagement> Line 13: <add address="*" maxconnection="24" />
Source File: C:WINDOWSMicrosoft.NETFramework64v2.0.50727Configmachine.config Line: 11 Where is the problem and how can I modify the machine.config so that I can finally control the maxconnection value?
I am writing an app that has a bit of process flow to it. On the save of a record, I need to check some fields to make sure they are not null. If they are not null, I will update a 'SectionComplete' field to true.
The thing is, I would like to store my fields in the web.config. So, I would like to have a string in the appsettings section that has a list of field names that are required. Then in my method, I would call these fields out and check each one for the specific record id, and then update the database.
I would like to do this in the web.config so we could add/remove columns without having to redeploy.
For example: my required fields are name, id, and phone. For section one to be labeled complete, all of these fields would need to be not null.
I have implemented Membership and Role Provider in my web site. Membership and Role information is stored in database created from aspnet_regsql option.
I want to store the access rights given to the pages in ASP.NET Configuation option in Database inspite of web.config file and want to give page wise add, edit, view and delete rights that should also be stored in database.
Is there any inbuit class like Membership and Role to add page access rights?
I'm wondering if modifying processModel in machine.config will have any effect on an IIS express integrated mode application? I'm trying to modify the maxWorkerThreads to at least 100 because I was comparing normal IIS vs IIS express on windows 7 using WCAT to see if scott was correct when he said IIS express has no connection limits. Although IIS express does show 30+ requests executing at the same time against the normal IIS limit of 10 the actual total requests per seconds are comparable between both and IIS express has much higher cpu usage and on average 70 requests queued vs 0 requests waiting for normal IIS! And the CPU is only about 70% on an quad core i7. surely there is room for optimization? additional details. I have uploaded the WCAT results run on windows 7, same script, to [URL]
IIS Express has slighter higher requests per second, and total transactions served than normal IIS. IIS Express is executing up to 50 requests at a time, while normal IIS on windows 7 is limited to 10 as designed. IIS express is using 30% higher cpu, probably because of additional requests it handles at a time. But on average Express requests take much longer to complete. see Request Execution Time performance counter and time analysis (first and last byte). Express is only able to beat IIS in total requests served because it can handle more requests at a time!
Could the fact that IIS express is printing each request to command line window even with trace set none be slowing it down. I also noticed a lot of additional modules registered in IIS express applicationhost.config that are not in IIS applicationhost.config. Could then extra debugging/tracing modules be causing the problem. I notice IIS express does not have FileCache and HTTPCache modules. Could that be why? I'm hoping asp.net experts can clarify how these results are possible if IIS express is not limited.
currently in our application we have an ApplicationConfiguration class. It is basically just a static class with const values specifying certain application-global configuration options. Some of these values will rarely if ever change and are only put into the configuration for elegance/cleanness.
Some of these values though do need to be different between production and development. So I'm considering making this class just a wrapper over Web.config. These values are checked many times throughout our codebase. If I change these from a const to a read-only getter that reads from Web.config will this affect compiler optimizations or make our application in any way slower?
I am doing a web project in asp.net. Now I am trying to keep each connection string for each user. And the user can decide which server he prefer. How to change this dynamically and where can I store this?. I happen heard about machine.config .Unfortunately i am not familiar with this. Can you just tell what it is and it's use.