5

I've developed a custom grid control that uses data-* attributes to configure how the grid is supposed to work (in a similar vein to how Bootstrap data API components work. For a particular deployment, I'm having to proxy my web application into another web application using IIS and Application Request Routing (ARR) + URL Rewrite. The proxying part is all done, I'm currently trying to configure the outbound rules for rewriting urls to match. For instance, I currently have rules set up such as:

  • Rewrite HTTP redirects by updating the Location: header.
  • Rewrite Html content for URIs in standard tags (e.g., A, Area, base, etc.)
  • Rewrite Css content for URI's that are relative (e.g. /cassette.axd -> /blog/cassette.axd).

The last issue I am having, is getting the URL rewrite module to accept my urls in data attributes, e.g., if my grid is such like:

<table data-grid data-query="/api/users/">

Should be rewritten as

<table data-grid data-query="/blog/api/users/">

I stress that all other tags, such as <a href and <img src work as expected and even a custom <property value tag is correctly rewritten. Just seems to by hypenated attributes.

I've tried adding a <customTags> section, with my custom tags in:

<customTags>
    <tags name="Bootgrid">
        <tag name="table" attribute="data-query" />
        <tag name="table" attribute="data-update" />
        <!-- This next tag WORKS -->
        <tag name="property" attribute="value" />
    </tags>
</customTags>

However, the above is not matching any attributes that have a hyphen. Not sure if this is actually solvable or not because I can't see anything in IIS configuration to set these.

Also annoyingly once you've created a set of Custom Tags in IIS, you can't seem to edit them again. :-/

4

3 回答 3

1

我遇到了同样的问题,并且似乎(尽管 Microsoft 未确认)IIS 无法处理包含 -

对我有用的解决方法是使用另一个出站规则。在此示例中,我尝试替换 img 标记中的 data-zoom-image 属性(您需要匹配和“行动”

<rule name="RewriteRelativePathsCustomTags1" preCondition="IsHtml" enabled="true">
    <match filterByTags="None" pattern="&lt;img ([^>]*)data-zoom-image=&quot;(.*?)&quot;([^>]*)>" />
    <action type="Rewrite" value="&lt;img {R:1}data-zoom-image=&quotYOUR VALUE TO REWRITE i.e /blog{R:2}&quot;{R:3}>" />
</rule>
<preConditions>
    <preCondition name="IsHtml">
        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
</preConditions>

希望这可以帮助

于 2015-06-02T11:03:33.713 回答
1

IIS 上的 ARR 似乎对包含带有破折号 (-) 的属性的标签存在问题。

更新到 v3.0.1952 似乎已经为我解决了这个问题,但我仍在调查。

于 2016-02-24T22:27:45.790 回答
0

相当晚了,但这在 2015年的 Release To Web 版本 (2.0.1952) 中得到了修复:

重要 - 此版本中的更改

  • Windows 10 和 Windows Server 2016 支持 - 现在可以使用此版本在 Windows 10 或 Windows Server 2016 上安装 URL Rewrite Module 2.0
  • 现在支持包含破折号的自定义属性。这是必需的,因为 HTML 5 具有以下确定 HTML 属性名称的规则:http: //www.w3.org/TR/html-markup/syntax.html#syntax-attributes
  • 包含 URL Rewrite 2.0(2014 年 6 月)的修补程序,如 KB2974666
于 2017-12-14T16:11:56.003 回答