ASP.NET的web.config:configSource对文件属性 [英] ASP.NET web.config: configSource vs. file attributes

查看:276
本文介绍了ASP.NET的web.config:configSource对文件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个的web.config - 文件在ASP.NET应用程序配置的某些部分,如的appSettings 是connectionStrings ,支持的属性 文件 configSource

什么是使用 文件之间 -attribute和 configSource -attribute?当你应该使用哪个属性,并可以同时使用?

 <?XML版本=1.0&GT?;
<结构>
  <文件的appSettings =AppSettings.config>
  < /的appSettings>
  <是connectionStrings configSource =ConnectionStrings.config>
  < /&是connectionStrings GT;
  <! - ... - >
< /结构>


解决方案

文件属性

configSource 属性

文件属性指定包含自定义设置,如您在web.config文件的appSettings进入做一个​​外部文件。
同时,在 configSource指定的外部文件属性包含您声明configSource的部分中的设置。例如,如果您使用的网页部分的configSource属性,则外部文件将包含的页面部分中的设置。


  

在specifified外部配置声明的自定义设置
  文件属性将与的appSettings的设置合并
  在web.config文件部分。在此同时,该configSource
  不支持合并,这意味着你必须移动整个
  部分设置到外部文件。


<一个href=\"http://www.$c$cproject.com/Messages/1463547/Re-difference-between-configSource-and-file-attrib.aspx\">http://www.$c$cproject.com/Messages/1463547/Re-difference-between-configSource-and-file-attrib.aspx

Within an web.config-file in an ASP.NET-application some sections of config, like appSettings and connectionStrings, supports the attributes file and configSource.

What is the difference between using the file-attribute and the configSource-attribute? When should you use which attribute and can you use both?

<?xml version="1.0"?>
<configuration>
  <appSettings file="AppSettings.config">
  </appSettings>
  <connectionStrings configSource="ConnectionStrings.config">      
  </connectionStrings>
  <!-- ... -->
</configuration>

解决方案

file attribute

configSource attribute

The file attribute specifies an external file containing custom settings like you do in the appSettings entry of the web.config file. Meanwhile, the external file specified in the configSource attribute contains the settings for the section which you declare the configSource for. For example, if you use the configSource attribute of the pages section, then the external file will contain the settings for the pages section.

The custom settings declared in the external config specifified in the file attribute will be merged with the settings in the appSettings section in the web.config file. In the meanwhile, the configSource does not support merging, it means that you'll have to move the entire section settings into the external file.

http://www.codeproject.com/Messages/1463547/Re-difference-between-configSource-and-file-attrib.aspx

这篇关于ASP.NET的web.config:configSource对文件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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