IIS反向代理不使用ASP.NET中的Response.Redirect()
我正在尝试使用教程
here,here和
here设置反向代理.
该站点在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 <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> 入境规则保持不变. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 如何通过自定义MessageFilter的方式利用按键方式操作控件滚
- asp.net-mvc – 如何在多个Asp.net MVC应用程序中使用通用布
- asp.net-mvc-4 – 在Visual Studio 2017 RC中无法识别ASP.N
- asp.net – 如何在.Net Core中间件中获取当前子域?
- asp.net – 和debug =“false”有什么区别?
- asp.net – 如何将Web应用程序项目转换为类库项目
- asp.net-mvc-3 – 可以在ASP.NET MVC 3上安装ASP.NET MVC 4
- asp.net-mvc – EF6“没有迁移已应用于目标数据库.”
- ASP.NET表单中的Paypal表单
- asp.net-mvc – 在ascx文件中使用Html.RenderPartial()
- asp.net – 无法加载mysql.web程序集
- asp.net-mvc – Web API IE9 JSON数据“你想打开
- .net – Nuget包,没有nuget包管理器?
- asp.net mvc 自定义pager封装与优化
- asp.net-mvc – 第一次只触发了Ajax.ActionLink
- 有没有办法确保(仅)在HTTPS协议上运行ASP.NET应用
- 为什么知道Asp.net的生命周期对Asp.net中的编码很
- asp.net-mvc – Razor视图没有布局
- asp.net-mvc-2 – 在发布网站后无法在asp.net mv
- vs .net CS0006 C# 未能找到元数据文件 .dll