将数据存储在web.config(custom section / appSettings元素)中,并将其存储在类中 [英] Storring data in web.config(custom section/appSettings element) vs storing it in a class

查看:184
本文介绍了将数据存储在web.config(custom section / appSettings元素)中,并将其存储在类中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么最好将数据存储在 web.config appSettings 元素(或自定义部分) c>文件比存储在类中?

Why is it better to store data inside an appSettings element (or inside a custom section) of a web.config file than to store it in a class?

一个参数是,通过使用自定义部分,我们不必在更改数据时重新编译代码,但这是一个弱的参数,特别是如果我们使用Web

One argument would be that by using custom sections we don’t have to recompile code when we change data, but that’s a weak argument, especially if we’re using Web Sites, which get recompiled automatically whenever code changes!



谢谢


Thank you

推荐答案

因为你可以改变它在飞行和使用它不考虑类结构。您的配置可以从每个开发人员机器到暂存到部署环境不同,通过独立于代码更改和维护一个文件,您可以利用站点不同区域的* .config掩码。

Because you can change it on the fly and use it without regard to class structure. Your configuration can vary from each developers machine to staging to deployment environment by changing and maintaining a single file independently of the code, and you can take advantage of *.config masking with different areas of your site.

硬编码任何可配置是一个失败的食谱,它会永远会咬你 - 这只是一个经验的问题,如果你不相信,那么你有,但有稍等一会儿!

Hard coding anything configurable is a recipe for failure and it absolutely will bite you - this is just a matter of experience, if you don't believe it then you have but to wait a little while!

这篇关于将数据存储在web.config(custom section / appSettings元素)中,并将其存储在类中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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