URL 根据验证后结果重写重定向
URL Rewrite redirection based on PostAuthenticate results
使用 Url 重写模块,我想根据在自定义身份验证过程中检索到的某些值来驱动重写。
在 PostAuthenticateRequest 期间,我尝试将 HTTP header 设置为 HttpContext.Current.Request.Headers.Add("name", "value");
,这在请求 object 离开 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 它能够找到数据。不幸的是,在提出请求之前我没有数据。
我可以在 IIS 模块中使用 headers 吗?如何从 PostAuthenticate 获取值到 URL 重写?
根据此博客 http://blogs.iis.net/wonyoo/relationship-between-application-request-routing-and-url-rewrite-modules,ARR 实现发生在 URL 重写之后的某个时刻,并且是外部服务器的实际代理。
据我了解,Url 重写模块在请求管道的早期提取 headers。因此 Url 重写模块将无法访问 headers。管道继续通过 Authentication 和 PostAuthentication 执行,并最终将代理的责任移交给 Application Request Routing。
使用 Url 重写模块,我想根据在自定义身份验证过程中检索到的某些值来驱动重写。
在 PostAuthenticateRequest 期间,我尝试将 HTTP header 设置为 HttpContext.Current.Request.Headers.Add("name", "value");
,这在请求 object 离开 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 它能够找到数据。不幸的是,在提出请求之前我没有数据。
我可以在 IIS 模块中使用 headers 吗?如何从 PostAuthenticate 获取值到 URL 重写?
根据此博客 http://blogs.iis.net/wonyoo/relationship-between-application-request-routing-and-url-rewrite-modules,ARR 实现发生在 URL 重写之后的某个时刻,并且是外部服务器的实际代理。
据我了解,Url 重写模块在请求管道的早期提取 headers。因此 Url 重写模块将无法访问 headers。管道继续通过 Authentication 和 PostAuthentication 执行,并最终将代理的责任移交给 Application Request Routing。