当通过代理服务器(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.