c# - vs 2012 Web.Config 转换

标签 c# visual-studio-2012 web.config-transform

我正在尝试添加一组 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/

相关文章:

c++ - CUDA 不适用于 Visual Studio 2013 - 工具包 4.2、5.5 和 6

c# - 使用 XDT 转换的 Web.config 进行部分替换

asp.net-core - 在 Asp.NET Core 中设置 web.config 转换

javascript - 拥有 2D Sprite 脸 3d 相机

c# - 如何在 C# 中将 bool 值转换为 int 并将其保存到 MySQL 表中?

c++ - 其中 ( new int*) 指向

web-config - Octopus Web.config 转换为客户端端点地址

c# - 覆盖 .NET 通用列表 <MyType>.Contains(MyTypeInstance)?

c# - Entity Framework 自动重命名多对多表而无需任何更改

visual-studio-2012 - Outlook 加载项 2013 - 功能区中的动画 Gif 图像