當通過代理服務器(A)時,應用服務器(B)發送的任何自引用鏈接需要重寫以使用代理作爲主機代替。在URL中重寫來自非HTML響應的標記中的內容重寫
這裏有一個例子:
從(B)響應包括:<a href="http://apps/path">path</a>
代理(A)需要爲改寫:通過創建檢查HTML響應出站規則<a href="http://proxy/path">path</a>
通常情況下,這樣做是對於包含url的標籤,查找對應用程序服務器的引用,並重寫它們。
這是一個正常的規則GUI version:
<outboundRules>
<rule name="Outbound Links" preCondition="IsHTML" enabled="true">
<match filterByTags="A, Form, IFrame, Img, Input, Link, Script" pattern="(https?:\/\/proxy|^)\/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true" />
<action type="Rewrite" value="http://apps/{R:2}" />
</rule>
當IsHTML
被定義爲:
<preConditions>
<preCondition name="IsHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="text\/html" />
</preCondition>
問題是,有些頁面內容是通過返回XHR請求。最起碼,這不符合HTML的先決條件。
,但我可以展開該規則還包括內容類型的xhr
但是,URL重寫仍然有麻煩解析返回的文本標籤,因爲它是無效的HTML。
這裏是什麼樣的反應看起來像一個例子:
|6383|updatePanel|ctl00_mainContentPlaceHolder_contentUpdatePanel|
<div id="ctl00_mainContentPlaceHolder_resultsPanel">
<a href="http://apps/path">path</a>
</div>
...
|0|hiddenField|__EVENTTARGET||0|hiddenField|__EVENTARGUMENT||0|hiddenField|
然而,當我這樣做,我得到的錯誤:
Sys.WebForms.PageRequestManagerParserErrorException:
The message received from the server could not be parsed.