简体   繁体   中英

Web.Config not transforming as expected

When I build my application using Visual Studio in either debug or release mode the connection string that I'm trying to transform doesn't get inserted into the finalised web.config file

Relevant section of web.config:

<?xml version="1.0" encoding="utf-8"?>

<configuration>
 <connectionStrings>

 </connectionStrings>
</configuration>

web.debug.config file:

<?xml version="1.0"?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <connectionStrings xdt:Transform="Replace" />


  <connectionStrings>
    <add name="DefaultConnection" xdt:Transform="Insert" providerName="System.Data.SqlClient"
connectionString="string value" />
  </connectionStrings>

</configuration>

I've tried the files with this site and it seems to work ok

原来,我的情况还不错,但是只有在发布网站时才生成修改后的web.config文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM