Redirecting custom tag attributes using IIS Url Rewrite 2.0 and ARR

I developed a custom mesh control that uses the data-* attributes to customize the mesh (in the same way as the components of the Bootstrap data API component). For a specific deployment, I need to proxy my web application to another web application using IIS and application request routing (ARR) + URL Rewrite. The proxy part has been completed, I'm currently trying to configure outgoing rules for rewriting URLs. For example, I have rules, for example:

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

The last problem I ran into is that the rewrite URL module accepts my URLs in data attributes, for example if my grid is like this:

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

Should be rewritten as

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

I emphasize that all other tags such as <a href and <img src work properly, and even the custom <property value tag is correctly rewritten. This seems to be due to negative attributes.

I tried to add 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 does not match hyphenated attributes. Not sure if this is really solvable or not, because I don't see anything in the IIS configuration to install them.

Also annoying, once you have created a set of custom tags in IIS, you cannot edit them again .: - /

+4
source share
3 answers

I had the same problem and it appears (although not confirmed by Microsoft) that IIS cannot process a user tag containing a -

The work that worked for me was to use another outgoing rule. In this example, I am trying to replace the data-zoom-image attribute in the img tag (you will need to replace & lt; img with & lt; table and data-zoom-image with the data request in both "match" and "action"

 <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 ie /blog{R:2}&quot;{R:3}>" /> </rule> <preConditions> <preCondition name="IsHtml"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> 

Hope this helps

+1
source

ARR on IIS seems to have problems with tags that include attributes with dashes (-) in them.

Updating to version 3.0.1952 seems to have solved the problem for me, but I'm still investigating.

0
source

Rather late, but this was fixed in 2015 in the version for the version for the web version (2.0.1952):

IMPORTANT - Changes in this release

  • Support for Windows 10 and Windows Server 2016. Now you can install URL Rewrite Module 2.0 on Windows 10 or Windows Server 2016 with this version.
  • Custom attributes containing dashes are now supported. This is necessary because HTML 5 has the following rules for defining HTML attribute names: http://www.w3.org/TR/html-markup/syntax.html#syntax-attributes
  • Includes a fix for Rewrite 2.0 URLs (June 2014), as in KB2974666
0
source

Source: https://habr.com/ru/post/1481973/


All Articles