asp.net中的webconfig文件并经常更改 [英] webconfig file in asp.net and change frequently

查看:256
本文介绍了asp.net中的webconfig文件并经常更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索关于在Web配置中放入大量键/值并经常更改它。结果是,经常更改Web配置并不好。创建两个webconfig,一个用于设置,另一个用于键/值更好或使用xml文件?建议改为什么?

是web配置的大小有限制吗?

解决方案

我个人会为不控制Web服务器行为的配置项使用单独的位置。单独的位置可以是XML文件,数据库等。如果您已在项目中使用数据库,我可能会使用它。



Web配置文件的最大大小通过控制HKLM\SOFTWARE\Microsoft\InetStp \Configuration\MaxWebConfigFileSizeInKB 注册表中的密钥。请参阅 IIS 7.0,IIS 7.5和IIS 8.0使用的注册表项的说明 [ ^ ]


取决于你在做什么,以及你想要保存什么。

如果它真的是大量并且你频繁地改变它那么我建议一个适当的数据库系统将是一个更好的选择 - 特别是如果您因用户输入而更改值。由于网站本身就是多用户,因此任何使用基于文本的文件(例如web.config或XML文件)的系统都会遇到问题,因为当其他用户需要访问该文件时,该文件正在使用中。这很好地解决了SQL Server或MySql。



就个人而言,我不会在web.config中存储任何会改变的内容:它存储有关如何更改的重要细节站点运行,除非我更新站点,否则不需要更改。它还使得很难组织开发(需要一组web.config设置)和生产(需要不同的设置)之间的分离。


使用app.config文件进行频繁更改元素

I Search about put large amounts of key / value in the web config and change it frequently. The result was that, frequently changing web configuration is not good.do create two webconfig ,one for settings and the other for key/value is better or use a xml file?what is proposed instead?
Is there a limit to the size of the web config?

解决方案

Personally I'd use a separate locations for such configuration items that are not controlling web server behaviour. The separate location could be a XML file, a database and so on. If you already use a database in your project, I'd probably use that.

The maximum size of the web config file is controlled via HKLM\SOFTWARE\Microsoft\InetStp\Configuration\MaxWebConfigFileSizeInKB key in registry. See Description of the registry keys that are used by IIS 7.0, IIS 7.5, and IIS 8.0[^]


Depends what you are doing, and what you want to save.
If it's really "large amounts" and you "change it frequently" then I'd suggest that a "proper" database system would be a better bet - particularly if you are changing the values as a result of user input. Because web sites are inherently multi user, any system which uses text based files (such as web.config or XML files) is going to run into problems because the file is in use when other users need to access it. SQL Server or MySql gets round this nicely.

Personally, I wouldn't store anything in web.config that was going to change: It stores important details about how the site runs, and shouldn't need to change except when I update the site. It also makes it difficult to organise the separation between development (which needs one set of web.config settings) and production (which needs different ones)


use app.config file for frequently change elements


这篇关于asp.net中的webconfig文件并经常更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆