asp.net - 有没有办法使用转换将新部分 "insert"放入 Web.Config?

标签 asp.net xslt web-config-transform xdt-transform

在我的 Web.Config 我有以下

  <system.webServer>

    <modules>
       **some code**
    </modules>
    <handlers>
       **some code**    
    </handlers>

  </system.webServer>

如何对其进行转换,以便将“安全”的新子部分注入(inject)“system.webServer”?到目前为止,我尝试和搜索的一切都失败了。

我想要的如下所示:
  <system.webServer>

    <modules>
       **some code**
    </modules>
    <handlers>
       **some code**    
    </handlers>

    <security>
      <ipSecurity allowUnlisted="false" denyAction="NotFound">
        <add allowed="true" ipAddress="10.148.176.10" />
      </ipSecurity>
    </security>

  </system.webServer>

最佳答案

找到了有效的解决方案。在我的 Web.Azure.Config 文件中,我必须添加以下内容:

  <system.webServer>
    <security xdt:Transform="Insert">
      <ipSecurity allowUnlisted="false" denyAction="NotFound">
        <add allowed="true" ipAddress="10.148.176.10" />
      </ipSecurity>
    </security>
  </system.webServer>

我在发布问题之前尝试了这个,但由于 Web.Config 的另一部分中的拼写错误,它出错了。

关于asp.net - 有没有办法使用转换将新部分 "insert"放入 Web.Config?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23709851/

相关文章:

.net - 是否使用 SharePoint(作为应用程序开发的基础)(与 ASP.NET 相比)

c# - 如何停止将重复的用户名添加到数据库表中?

asp.net - 通过 web.config 转换,如何在顶部注入(inject)规范 url 规则?

html - XSLT 更改内部字符串

XSLT 应该只处理具有相同日期的节点一次

c# - 使用 msbuild 命令行转换 web.config

xpath - Web 配置转换 : Insert If Not Exists

asp.net - 在两个站点之间共享身份验证 cookie/成员(member)提供商 - 第二个站点从不进行身份验证

c# - 重定向到当前友好的 URL(有或没有 url 变量)

javascript - 将 XML 数据解析为动态 HTML Select 语句