web.config和普通xml文件之间的区别,用于存储应用程序设置(Difference between web.config and normal xml file for storing application settings)

我有一个应用程序,它有一些特定的设置,如erroremailid,maxcapcount等。我将这些值存储在appsetting块中。 任何人都可以告诉我在以下两个选项之间哪个更好(性能明智):1。在web.config中存储设置2.在普通xml文件中存储设置然后读取它们



I have an application which have some specific settings like erroremailid, maxcapcount etc. I am storing these values in appsetting block. Can anybody tell me which will be better (performance wise) between following two options: 1. Storing settings in web.config 2. Storing settings in normal xml file and then reading them

Some articles specifying the performance difference will also be good.

Thanks Ashwani



.NET的工作方式是从应用程序配置文件中检索某些设置(不仅仅是appSettings部分),该文件是ASP.NET的web.config和可执行应用程序的exefile.exe.config 。



仍然。 .NET将从web.config获取appSettings,因此您只能在其他文件中放入其他类型的设置,然后您必须自己手动读取这些设置,不确定是否可以指示ConfigurationManager从其他文件读取。


The point is not about performances, why do you think the .NET framework would be any faster in reading one xml file vs another one?

The way .NET works is that certain settings (not only the appSettings section) are retrieved from the application configuration file which is web.config for ASP.NET and exefile.exe.config for executable applications.

in executables like windows forms applications you can also save settings from the app at runtime in the config file but in ASP.NET even if the APIs being the same will let you call the save method, the web.config will not be updated as it's opened as readonly because every time it is changed IIS restarts the web application.

there is no way to imagine that putting some other custom settings in another separated XML file would be any slower or any faster, the advantage vs the web.config would be that you can edit such xml file anytime without the web app to restart as it would happen anytime you save changes in web.config.

still. .NET will get the appSettings from web.config so you can put in another file only other kind of settings and then you have to read those settings yourself by hand, not sure if you can instruct the ConfigurationManager to read from another file.

There are many other sections inside the web.config that are taken by other parts of the application and if you would move them somewhere .NET would not automatically take those for you, for example the default SMTP Server.