我正在尝试添加一组 URL 重写规则,但仅限于我正在开发的网站的已发布版本。
如果我想更改连接字符串值,我会找到各种示例,但我找不到如何添加主 web.config 中已经存在的内容的示例。
我需要的是在system.WebServer下添加rewrite节点。
最佳答案
您只需在要在转换期间添加的标记中使用 xdt:Transform="Insert"
属性。在这里阅读更多相关信息:http://msdn.microsoft.com/en-us/library/dd465326.aspx
您可以将以下示例作为起点(这是我的 Web.Release.config
文件):
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- Enable static content caching in release mode -->
<system.webServer xdt:Transform="Insert">
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" cacheControlCustom="public" />
</staticContent>
</system.webServer>
</configuration>
关于c# - vs 2012 Web.Config 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17779185/