MagicChunks未写入web.config属性



我的web.config:中有这个块

<rewrite>
<rules>
<rule name="Remove Trailing Slash" stopProcessing="false">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="Angular UI Router - HTML5 Mode" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="/api/" negate="true" />
</conditions>
<action type="Rewrite" url="/app/" />
</rule>
</rules>
</rewrite>

在Azure发布管道中,我使用MagicChunks工具转换web.config以将第二个action元素的url属性更改为"/",但失败了。我的转变是:

{
"rewrite/rules/rule/action[@type='Rewrite' and @url='/app/']/@url": "/"
}

它抛出的错误是:

System.ArgumentException:***There***is***empty***items***in***the***path.

当要转换的属性不是用作目标路径的属性时,如何将其作为目标?

不确定web.config的外观,但转换语法有问题。检查该扩展名中的文档。你应该使用这样的东西:

{
"rewrite/rules/rule[@name='Angular UI Router - HTML5 Mode']/action[@type='Rewrite']/@url": "/"
}

由于我以这种方式测试了您的脚本:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
</system.web>
<rewrite>
...
</rewrite>
</configuration>

所以我实际上用了一些类似的东西:

{
"configuration/rewrite/rules/rule[@name='Angular UI Router - HTML5 Mode']/action[@type='Rewrite']/@url": "/"
}

注意web.config中的根节点。然后将url属性替换为"/"应该会很好。如果我误解了什么,请告诉我:(

最新更新