对于 ASP.NET 4.5 应用程序,我使用 appSettings 进行电子邮件配置。我也在使用 connectionStrings
appSettings 需要包含在 connectionStrings 之前而不是 configSections 之前
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="ContactEmail0" value="service@davincispainting.com" />
<add key="ContactEmail1" value="estimate@davincispainting.com" />
</appSettings>
<connectionStrings>
<!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-DAV3-20150302043828.mdf;Initial Catalog=aspnet-DAV3-20150302043828;Integrated Security=True" providerName="System.Data.SqlClient" />-->
<!--<add name="connectionString" connectionString="data source=localhost;Initial Catalog=*****;User ID=sa;Password=*****;" providerName="System.Data.SqlClient" />-->
<!--<add name="connectionString" connectionString="data source=localhost;Initial Catalog=Davincis3;User ID=*****;Password=*****;" providerName="System.Data.SqlClient" />-->
<!--<add name="connectionString" connectionString="data source=DELLLAPTOP-PC\SQLSERVEREXPRESS;Initial Catalog=Davincis3;User ID=sa;Password=*****;" providerName="System.Data.SqlClient" />-->
<add name="connectionString" connectionString="data source=DELLLAPTOP-PC\SQLEXPRESS;Initial Catalog=Davincis3;User ID=sa;Password=*****;" providerName="System.Data.SqlClient" />
</connectionStrings>
...