是否可以在web.config属性中使用参数值

时间:2016-02-10 13:14:25

标签: asp.net .net web-config

我想要实现的是设置web.config规则及其属性的参数,主要是为了避免重复。例如(来自重写模块):

 <rule name="Test11" stopProcessing="true">
    <match url="test11" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
      <add input="{HTTP_USER_AGENT}" pattern="midp|mobile|phone|android|iphone|ipad" />
    </conditions>
    <action type="Redirect" url="test1/{R:0}" appendQueryString="true" />
  </rule>

  <rule name="Test22" stopProcessing="true">
    <match url="test22" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
      <add input="{HTTP_USER_AGENT}" pattern="midp|mobile|phone|android|iphone|ipad" />
    </conditions>
    <action type="Redirect" url="test2/{R:0}" appendQueryString="true" />
  </rule>

转换为:

<rule name="Test11" stopProcessing="true">
    <match url="test11" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
      <add input="{HTTP_USER_AGENT}" pattern="`[MyParameter]`" />
    </conditions>
    <action type="Redirect" url="test1/{R:0}" appendQueryString="true" />
  </rule>

  <rule name="Test22" stopProcessing="true">
    <match url="test22" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
      <add input="{HTTP_USER_AGENT}" pattern="**[MyParameter]**" />
    </conditions>
    <action type="Redirect" url="test2/{R:0}" appendQueryString="true" />
  </rule>

请注意,重写规则不是主要问题,但使用参数的能力是。

0 个答案:

没有答案