web-config - 从 web.config 中分离 ConnectionStrings 和 mailSettings?可能的?

标签 web-config connection-string

是否可以将 ConnectionStrings 和 mailSettings 与 web.config 分开?

由于开发和测试,开发环境具有不同的连接字符串和 smtp 邮件的 IP 地址。我们不想使用实时机器和实时 IP 地址进行测试和开发。

是否可以?

最佳答案

我在 MSDN 上找到了答案:

<configuration>
    <connectionStrings configSource="connections.config"/> 
</configuration>

随文件 connections.config包含
<connectionStrings>
   <add name="name" connectionString="conn_string" providerName="System.Data.SqlClient" />
   <add name="name2" connectionString="conn_string2" providerName="System.Data.SqlClient" />
</connectionStrings>

关于web-config - 从 web.config 中分离 ConnectionStrings 和 mailSettings?可能的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6582970/

相关文章:

WCF 错误 - 找不到与方案匹配的基地址

c# - 你能从 web.config 文件的其他地方提取 log4net AdoNetAppender 的 connectionString 吗?

web-config - Octopus Web.config 转换为客户端端点地址

powershell - 密码中包含 "$"的 SQL Server 连接字符串

c# - 如果配置在字符串中,是否使用 new ChannelFactory<TChannel>(string)?

c# - 加密 Web.Config

c# - 从连接字符串中获取用户名和密码的正确方法?

c# - OleDb 连接字符串中扩展属性的规范?

c# - 在 C# 服务中获取连接字符串

c# - System.Configuration.ConfigurationManager.ConnectionStrings 没有配置连接字符串