【发布时间】:2016-12-09 15:51:25
【问题描述】:
使用 Url Rewrite 模块,我想根据在自定义身份验证过程中检索到的某些值来驱动重写。
在 PostAuthenticateRequest 期间,我尝试使用HttpContext.Current.Request.Headers.Add("name", "value"); 设置 HTTP 标头,该标头在离开 HTTPModule 之前在请求对象上可见。
但是在 URL 重写中,一个非常基本的条件失败了,因为 HTTP_name 下没有文本。
<rule name="customrule" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_name}" pattern=".+" /> <!-- doesn't work -->
<!-- <add input="{HTTP_name}" pattern=".*" /> works -->
</conditions>
<action type="Rewrite" url="https://someotherdomain/{R:0}" />
</rule>
将条件上的模式更改为 .* 让规则通过,但 URL 显示为 https:///{R:0}。如果我手动添加name Header before 从服务器请求资源它能够找到数据。不幸的是,在提出请求之前,我没有数据。
我可以跨 IIS 模块使用标头吗?如何从 PostAuthenticate 获取值到 URL Rewrite?
【问题讨论】:
标签: c# iis url-rewriting iis-7.5 arr