IIS反向代理不使用ASP.NET中的Response.Redirect()

我正在尝试使用教程 here,herehere设置反向代理.

站点在localhost:8080上设置,反向代理使用localhost:8080 / myProxy.

处理标准链接时,一切都很好.我可以查看代理URL并按预期查看所有内容.来自localhost:8080 / myProxy / default.aspx的链接按预期转到localhost:8080 / myProxy / about.aspx.

我遇到的问题是,在使用.NET Response.Redirect()的情况下,url会更改为网站的实际位置而不是代理.

链接来自localhost:8080 / myproxy / default.aspx – >本地主机:8080 / about.aspx.

我该如何解决这个问题?

这是我的配置:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <urlCompression doStaticCompression="false" doDynamicCompression="false" 
                    dynamicCompressionBeforeCache="false" />
    <rewrite>
        <rules>
            <rule name="Reverse Proxy to my site" stopProcessing="true">
                <match url="^myProxy/(.*)" />
                <action type="Rewrite" url="http://localhost:8080/{R:1}" />
            </rule>
        </rules>

        <outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                <match filterByTags="A,Area,Base,Form,Frame,Head,IFrame,Img,Input,Link,Script"
                       pattern="^http(s)?://localhost:8080/(.*)" />
                <action type="Rewrite" value="/myProxy/{R:2}" />
            </rule>
            <rule name="RewriteRelativePaths" preCondition="ResponseIsHtml1">
                <match filterByTags="A,Script" 
                       pattern="^/(.*)" negate="false" />
                <action type="Rewrite" value="/myProxy/{R:1}" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>

    </rewrite>
</system.webServer>

解决方法

很抱歉回答我自己的问题,但我认为值得为其他人提供信息:

使用Response.Redirect时,出站规则开始起作用.使用fiddler查看请求有助于解决链接发生的问题.

Response.Redirect()试图发送到/About.aspx(在响应标头中传输).

正则表达式没有提到这一点.

我需要的唯一出站规则是setting up Response_location如下:

<rule name="Response Status Update" preCondition="ResponseStatus" stopProcessing="true">
  <match serverVariable="RESPONSE_Location" pattern="^/(.*)" />
  <action type="Rewrite" value="http://myServer:8080/myProxy/{R:1}" />
</rule>

入境规则保持不变.

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...