在web.config里使用configSource分隔各类配置
来源:互联网 发布:java中offset 编辑:程序博客网 时间:2024/05/17 03:47
configSource简介一:
在web.config 中:
<myconfig configSource="path\xxx.config" />
在自定义path\xxx.config中:
<myconfig>
<mmm> dd </mmm>
</myconfig>
注意,configSouce中的文件路径只能为相对物理路径,也就是只能为反斜杠(\),不能用斜杠(/)。
在网站运行时,如果修改 Web.Config 文件会引起站点的重启,而修改 xxx.Config 文件则不会.
configSource简介二:
大型项目中,可能有多个Service,也就是会有一堆配置,而这些配置文件如果散落在各个项目的web.config里,那维护量将是非常巨大的,所以有人使用configSource将各咱文件分开放,然后Copy到各处,这样以来配置文件看起来就很模块化了,但这样Copy维护起来还是很麻烦,所以有高人提出公共配置的概念,将这些配置文件放到一个公用目录,然后在各个目录下建立一个虚拟文件夹指向那个公共目录(Junctionhttp://technet.microsoft.com/en-us/sysinternals/bb896768.aspx,如想了解更多可访问:多站点共享:共享配置)天下太平了,要添加修改只用改这一个文件夹的内容就可以了。
我们用到的有:
<appSettings configSource="VConfigs\DEV\appSettings.config" />
<system.serviceModel> <services configSource="VConfigs\DEV\WCF.services.config" /> <bindings configSource="VConfigs\DEV\WCF.bindings.config" /> <behaviors configSource="VConfigs\DEV\WCF.behaviors.config" /> <client configSource="VConfigs\DEV\WCF.client.config" /> </system.serviceModel>
参考内容:
ConfigSource attribute on system.serviceModel section
The configSource attribute was firstly introduced in .NET framework 2.0 to support external configuration files.
This attribute can be added to any configuration section to specify a an external file for that section. Using an external configuration source can be useful in many scenarios. For instance, you could place a section into an external configSource if you need an easy method to swap settings for the section depending on the environment (development, test, or production), or you need granular control over permissions.
Unfortunately, the system.serviceModel section group does not support this attribute. If you try to add it, you will receive the following exception:
The attribute 'configSource' cannot be specified because its name starts with the reserved prefix 'config' or 'lock'
"configSource" attribute is a property comes from the section Information class.
Every ConfigurationSection in .net framework 2.0 configuration scheme system
has a property of a section Information where the config source is declared.
you can use this attribute on the different sections under system.serviceModel such as services, behaviors or bindings.
For instance, the configuration file could look like this,
<configuration>
<system.serviceModel>
<services configSource="Services.config" />
<bindings configSource="Bindings.config" />
<behaviors configSource="Behaviors.config" />
</system.serviceModel>
</configuration>
And then, each file contains the corresponding section.
Services.config
<services>
<service name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<host>
<baseAddresses>
<addbaseAddress="http://localhost:8000/servicemodelsamples/service"/>
</baseAddresses>
</host>
<!-- this endpoint is exposed at: net.tcp://localhost:9000/servicemodelsamples/service -->
<endpointaddress="net.tcp://localhost:9000/servicemodelsamples/service"
binding="netTcpBinding"
bindingConfiguration="Binding1"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
Bindings.config
<bindings>
<netTcpBinding>
<binding name="Binding1"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows"protectionLevel="EncryptAndSign" />
</security>
</binding>
</netTcpBinding>
</bindings>
Behaviors.config
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
转自:http://www.cnblogs.com/xiurui12345/archive/2012/05/10/2493783.html
- 在web.config里使用configSource分隔各类配置
- 在web.config里使用configSource分隔各类配置
- 在web.config里使用configSource分隔各类配置
- 在Web.Config文件中使用configSource
- 通过configSource提高web.config配置灵活性
- 通过configSource提高web.config配置灵活性
- 通过configSource提高web.config配置灵活性
- 通过configSource提高web.config配置灵活性
- Web.Config文件中使用configSource
- 使用 ConfigSource 特性 拆分 Web.config 文件
- [asp.netMVC]通过configSource提高web.config配置灵活性
- 在Web.Config文件中使用configSource,避免动态修改web.config导致asp.net重启(另添加一个Config文件用于管理用户数据)
- 在web.config里自定义配置节
- c#web.config里配置webservice调用
- 在web.config中配置
- session在 web.config配置
- 在Web.config里设置数据库连接字符串
- 在web.config里写access数据库连接
- myeclipse 8.5 优化
- 开发工具-Eclipse(25个最佳闪亮的Eclipse开源工具)
- 多字节字符串与宽字符串的转换
- 文件系统列表
- 百度测试一面
- 在web.config里使用configSource分隔各类配置
- Ubuntu热键
- live555 H264封包原理
- 电脑按键大全
- ThinkPHP模板的应用
- Windows+apache+php+mysql环境搭建
- 监控mysql执行的语句
- RFC791中文
- delphi中指针的用法