0

我需要以下每种表达式类型的一些 web.config 示例:

$number

与组号 number 匹配的最后一个子字符串。

$<name>

由(?<name>)匹配的名为 name 的组匹配的最后一个子字符串。

${property}

计算表达式时的属性值。

${transform(value)}

对指定值调用转换的结果。

${map:value}

使用映射映射指定值的结果。如果不存在映射,则替换为空字符串。

${map:value|default}

使用映射映射指定值的结果。如果不存在映射,则替换为默认值。

样本:

<rewriter>
    <if url="/tags/(.+)" rewrite="/tagcloud.aspx?tag=$1" />
    <!-- same thing as <rewrite url="/tags/(.+)" to="/tagcloud.aspx?tag=$1" /> -->
</rewriter>

非常感谢 !

4

1 回答 1

1

这是我发现/猜测的。未测试。

$number : http://urlrewriter.net/index.php/support/using

<rewrite url="^(.*)/(\?.+)?$" to="$1/default.aspx$2?" />

$1 matches (.*)
$2 matches (\?.+)

$< name > :这个我在正则表达式上不太确定,在文档中找不到任何东西

<rewrite url="^(?<group1>(.*))/(\?.+)?$" to="$<group1>/default.aspx$2?" />

$<group1> matches 

${property}:http ://urlrewriter.net/index.php/support/reference/actions/set-property

<set property="branch" value="$3" />
<rewrite to="/showbranch.aspx?branch=${branch}" />

${transform(value)}:http ://urlrewriter.net/index.php/support/reference/transforms

<set property="transform-name" value="lower" />
<set property="value-to-transform" value="THIS WAS UPPER CASE" />

<redirect to="/WebForm1.aspx?q=${encode(${${transform-name}(${value-to-transform})})}" />

results in "/WebForm1.aspx?q=this+was+upper+case"

${map:value}:http ://urlrewriter.net/index.php/support/reference/transforms/static

<mapping name="areas">
    <map from="sydney" to="1" />
    <map from="melbourne" to="2" />
    <map from="brisbane" to="3" />
</mapping>

<rewrite to="/area.aspx?area=${areas:$3}" />

results in "/area.aspx?area=brisbane"

${地图:值|默认}

<mapping name="areas">
    <map from="sydney" to="1" />
    <map from="melbourne" to="2" />
    <map from="brisbane" to="3" />
</mapping>

<rewrite to="/area.aspx?area=${areas:$4|perth}" />

results in "/area.aspx?area=perth"
于 2010-03-30T03:53:26.207 回答