Web配置转换不起作用 [英] Web Config Transform not working
问题描述
在.NET MVC 3.0应用程序中,我在appSettings
中具有以下配置:
In a .NET MVC 3.0 Application I have the following configuration in appSettings
:
<appSettings>
<add key="SMTPHost" value="mail.domain.com"/>
<add key="SMTPUsername" value="user@gmail.com"/>
<add key="SMTPPort" value="25"/>
<add key="SMTPPwd" value="mypassword"/>
<add key="EmailFrom" value="notific@gmail.com"/>
</appSettings>
对于调试,我定义了以下配置转换:
For debugging, I have the following configuration transform defined:
<appSettings>
<add key="SMTPPort" value="58" xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>
然后我以调试模式运行该应用程序,但是我的SMTP端口仍然从web.config
而不是web.Debug.config
获取值.
And I run the application in debug mode, but my SMTP port is still taking the value from the web.config
, not web.Debug.config
.
任何人都可以建议此配置有什么问题吗?
Can anyone suggest what could be wrong in this configuration?
推荐答案
Web.config转换仅作为发布操作的一部分来应用.
The Web.config transforms are only applied as part of a publish operation.
如果希望将此操作作为app.config
生成操作的一部分进行,则可以使用SlowCheetah-XML Transforms Visual Studio插件:
If you wish this to be done as part of an app.config
build operation, then you can use the SlowCheetah - XML Transforms Visual Studio plugin:
http://visualstudiogallery.msdn.microsoft.com/69023d00- a4f9-4a34-a6cd-7e854ba318b5
这篇关于Web配置转换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!