[英]Rewriting custom tag attributes using IIS Url Rewrite 2.0 and ARR
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: 我开发了一个自定义网格控件,它使用
data-*
属性来配置网格应该如何工作(与Bootstrap数据API组件的工作方式类似。对于特定部署,我必须代理我的Web应用程序使用IIS和应用程序请求路由(ARR)+ URL重写进入另一个Web应用程序。代理部分全部完成,我正在尝试配置重写URL匹配的出站规则。例如,我目前有规则设置这样如:
Location:
header. Location:
标头重写HTTP重定向。 The last issue I am having, is getting the URL rewrite module to accept my urls in data attributes, eg, if my grid is such like: 我遇到的最后一个问题是让URL重写模块接受数据属性中的url,例如,如果我的网格是这样的:
<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. 我强调所有其他标记,例如
<a href
和<img src
按预期工作,甚至自定义<property value
标记也被正确重写。 Just seems to by hypenated attributes. 似乎只是通过夸大的属性。
I've tried adding a <customTags>
section, with my custom tags in: 我尝试添加
<customTags>
部分,我的自定义标记位于:
<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.
不确定这是否真的可以解决,因为我在IIS配置中看不到任何设置这些内容。
Also annoyingly once you've created a set of Custom Tags in IIS, you can't seem to edit them again. 还烦人的是,一旦你在IIS中创建了一组自定义标签,你似乎无法再次编辑它们。 :-/
: - /
I had the same issue, and it appears (although not confirmed by Microsoft) that IIS cannot handle a custom tag that contains a - 我有同样的问题,它似乎(虽然没有得到Microsoft确认)IIS无法处理包含 - 的自定义标记 -
A work around that worked for me was to use another outbound Rule. 解决这个问题的方法是使用另一个出站规则。 In this example I am attempting to replace the data-zoom-image attribute within an img tag (You will need to replace the <img with <table and data-zoom-image with data-query in both the "match" and "action"
在这个例子中,我试图替换img标记中的data-zoom-image属性(你需要在“匹配”和“匹配”中用&lt; img和&lt; table和data-zoom-image替换数据查询 “行动”
<rule name="RewriteRelativePathsCustomTags1" preCondition="IsHtml" enabled="true">
<match filterByTags="None" pattern="<img ([^>]*)data-zoom-image="(.*?)"([^>]*)>" />
<action type="Rewrite" value="<img {R:1}data-zoom-image="YOUR VALUE TO REWRITE i.e /blog{R:2}"{R:3}>" />
</rule>
<preConditions>
<preCondition name="IsHtml">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
Hope this helps 希望这可以帮助
ARR on IIS seems to have issues with tags that include attributes with a dash (-) in them. IIS上的ARR似乎存在标记问题,其中包含带有短划线( - )的属性。
Updating to v3.0.1952 seems to have solved the issue for me, but I'm still investigating. 更新到v3.0.1952似乎已经解决了我的问题,但我仍在调查。
Rather belated, but this was fixed back in 2015 in the Release To Web version (2.0.1952): 相反,但这在2015年的Release To Web版本(2.0.1952)中得到了修复:
IMPORTANT - Changes in this release
重要信息 - 此版本中的更改
- Windows 10 and Windows Server 2016 Support - It is now possible to install URL Rewrite Module 2.0 on Windows 10 or Windows Server 2016 with this release
Windows 10和Windows Server 2016支持 - 现在可以在此版本的Windows 10或Windows Server 2016上安装URL Rewrite Module 2.0
- Custom attributes containing dashes are now supported.
现在支持包含短划线的自定义属性。 This is required as HTML 5 has the following rules for determining HTML attribute names: http://www.w3.org/TR/html-markup/syntax.html#syntax-attributes
这是必需的,因为HTML 5具有以下用于确定HTML属性名称的规则: http : //www.w3.org/TR/html-markup/syntax.html#syntax-attributes
- Incorporates Hotfix for URL Rewrite 2.0 (June 2014) as in KB2974666
包含URL Rewrite 2.0的修补程序(2014年6月),如KB2974666所示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.