创建XML自己的设置 [英] create your own settings in xml
问题描述
我在ASP.NET项目中,我需要给几个参数的管理员是要安装的网站,如:
I'm in a ASP.NET project where I need to give several parameters to the administrator that is going to install the website, like:
AllowUserToChangePanelLayout
AllowUserToDeleteCompany
等等......
etc...
我的问题是,将添加到web.config文件中这是好事,用我自己的configSession或者添加为轮廓可变因素?或者我应该为此创建XML文件?
My question is, will be a good thing to add this into the web.config file, using my own configSession or add as a profile varibles? or should I create a XML file for this?
你做什么工作,什么是缺点和的收藏?
What do you do and what are the cons and favs?
我本来想过的web.config,但后来我意识到,我应该乱用网站的配置和我自己的web应用程序的配置,我应该创建一个不同的文件,他们读我的这个帖子,现在我对这个地方...我应该做这做那?
I originally thought about web.config but I then realized that I should mess up with Website configurations and my own web app configuration and that I should create a different file, them I read this post and now I'm on this place... should I do this or that?
推荐答案
我通常使用设置 - 通过项目属性可用 - 设置。这些可以被编辑和保存在code和我写一个形式/网页进行编辑。
I usually use Settings - available via the project properties - Settings. These can be edited and saved in code, and I write a form / web page to edit them.
如果你想使用XML配置,有一个属性,叫做文件读取外部文件。
你可以有一个web.config文件和someothername.config文件。该someothername.config将有类似的设置:
If you want to use the XML configuration, there's an attribute called file that reads external files. You could have a web.config file and a someothername.config file. The someothername.config would have settings like:
<appSettings>
<add key="ConnString" value="my conn string" />
<add key="MaxUsers" value="50" />
</appSettings>
和web.config中会有
And the web.config would have
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="ExternalWeb.config">
<add key="MyKey" value="MyValue" />
</appSettings>
</configuration>
请参阅 DevX 以我偷的例子。
这篇关于创建XML自己的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!