簡體   English   中英

使用IIS Url Rewrite 2.0和ARR重寫自定義標記屬性

[英]Rewriting custom tag attributes using IIS Url Rewrite 2.0 and ARR

我開發了一個自定義網格控件,它使用data-*屬性來配置網格應該如何工作(與Bootstrap數據API組件的工作方式類似。對於特定部署,我必須代理我的Web應用程序使用IIS和應用程序請求路由(ARR)+ URL重寫進入另一個Web應用程序。代理部分全部完成,我正在嘗試配置重寫URL匹配的出站規則。例如,我目前有規則設置這樣如:

  • 通過更新Location:標頭重寫HTTP重定向。
  • 為標准標簽中的URI重寫Html內容(例如,A,區域,基礎等)
  • 重寫相對URI的Css內容(例如/cassette.axd - > /blog/cassette.axd)。

我遇到的最后一個問題是讓URL重寫模塊接受數據屬性中的url,例如,如果我的網格是這樣的:

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

應改寫為

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

我強調所有其他標記,例如<a href<img src按預期工作,甚至自定義<property value標記也被正確重寫。 似乎只是通過誇大的屬性。

我嘗試添加<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>

但是,上述內容不匹配任何帶連字符的屬性。 不確定這是否真的可以解決,因為我在IIS配置中看不到任何設置這些內容。

還煩人的是,一旦你在IIS中創建了一組自定義標簽,你似乎無法再次編輯它們。 : - /

我有同樣的問題,它似乎(雖然沒有得到Microsoft確認)IIS無法處理包含 - 的自定義標記 -

解決這個問題的方法是使用另一個出站規則。 在這個例子中,我試圖替換img標記中的data-zoom-image屬性(你需要在“匹配”和“匹配”中用&lt; img&lt; tabledata-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>

希望這可以幫助

IIS上的ARR似乎存在標記問題,其中包含帶有短划線( - )的屬性。

更新到v3.0.1952似乎已經解決了我的問題,但我仍在調查。

相反,但這在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所示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM