[英]web.config debug/release not working
in my web.config 在我的web.config中
<connectionStrings>
<add name="Context" connectionString="Server=tcp:database.windows.net,1433;Database=DbDev;User ID=xxxx;Password=xxxx.;Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
<connectionStrings/>
my web.Debug.config 我的web.Debug.config
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="Context" connectionString="Server=tcp:database.windows.net;Database=DbDev;
User ID=xxxx;Password=xxxx.;
Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
<customErrors mode="Off" xdt:Transform="Replace">
</customErrors>
</system.web>
</configuration>
in my web.Release.config 在我的web.Release.config中
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="Context" connectionString="Server=tcp:database.windows.net;
Database=DbProd;User ID=xxxx;Password=xxxx.;
Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient"
xdt:Transform="Replace" xdt:Locator="Match(name)" />
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<customErrors defaultRedirect="GenericError.htm" mode="On" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
</system.web>
</configuration>
it's just not getting the production database DbProd 只是没有得到生产数据库DbProd
我认为在VS中运行``发布''模式时,它将转换web.release.config文件,但是由于某些原因(缓存?bin?)它不会使用它。但是,当我在Azure环境中发布它时,那么它将正确获取配置
xdt:Locator="Match(name)"
means transformed values will be applied if name
attribute values match. xdt:Locator="Match(name)"
表示如果name
属性值匹配,则将应用转换后的值。
In web.config you have 在web.config中
<add name="Context"
But in web.release.config 但是在web.release.config中
<add name="PoqContext"
Changing connection string names to same value should help you. 将连接字符串名称更改为相同的值应该会有所帮助。 Also, take a look at Web.config Transformation Syntax for other available options
另外,请查看Web.config转换语法以了解其他可用选项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.