[英]Web Deploy deleting IIS website custom configuration
I'm using Web Deploy (from VS2013) to publish an ASP.NET MVC site to an IIS 7.5. 我正在使用Web Deploy(来自VS2013)将ASP.NET MVC网站发布到IIS 7.5。
I added some URL rewrite rules and custom HTTP response headers through IIS manager. 我通过IIS管理器添加了一些URL重写规则和自定义HTTP响应标头。
The problem is everytime I deploy a new version of the site, this extra configuration is deleted. 问题是每次我部署该网站的新版本时,都会删除此额外的配置。
Is this the expected behaviour or is there something wrong? 这是预期的行为还是有问题? How can I keep these custom settings on each deploy?
如何在每次部署中保留这些自定义设置?
UPDATE 更新
So I understood I need to put these changes in the web.config
. 所以我知道我需要将这些更改放入
web.config
。 I'm trying to put them in the Web.Release.config
but it's not being added to the deployed web.config
. 我正在尝试将它们放在
Web.Release.config
但没有将其添加到已部署的web.config
。 I guess I'm missing some XDT:Transform
rule. 我想我缺少一些
XDT:Transform
规则。
This is what I got in my Web.Release.config
(yes, the publishing profile is using this Release config). 这是我在
Web.Release.config
(是的,发布配置文件正在使用此Release配置)。
<configuration>
<!-- some other stuff -->
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="mydomain.com" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Turn the build action of your web.config to None. 将您的web.config的生成操作转到无。 That will prevent the file from being deployed each time you publish.
这样可以防止每次发布时都部署文件。
Edit 编辑
For inserting entire sections into a web.config from the web.release.config, you need the xdt:Transform="Insert" added like so: 为了将整个部分从web.release.config插入到web.config中,您需要添加xdt:Transform =“ Insert”,如下所示:
<system.webServer xdt:Transform="Insert">
<rewrite>
<rules>
<rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="mydomain.com" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Ok so I understood I need to add this custom configuration in the web.config using XDT:Transform
. 好的,我理解我需要使用
XDT:Transform
在web.config中添加此自定义配置。
I added this to the Web.Release.config
and it worked: 我将此添加到
Web.Release.config
并且可以正常工作:
<system.webServer>
<rewrite xdt:Transform="Insert">
<rules>
<rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="mydomain.com" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.