的Response.Redirect条头引荐 - 可以添加回来? [英] Response.Redirect strips Header Referrer - Possible to Add it Back?
问题描述
我使用的Response.Redirect将用户重定向到另一台服务器上下载文件,而其他服务器检查头,以确保它来自正确的服务器...但它似乎的Response.Redirect剥离头从响应。
I'm using a Response.Redirect to redirect users to another server to download a file, and the other server is checking the header to ensure it came from the correct server... however it seems Response.Redirect strips the headers from the Response.
有谁知道我可以添加标题回来?我尝试过:
Does anybody know how i can add the headers back? I've tried:
Response.AddHeader("Referer", "www.domain.com");
但接收页面测试假,当我检查引荐头设置。
But the receiving page tests false when i check if the Referrer header is set.
任何建议如何我能得到这个工作,除了为用户点击显示按钮等(我想保持对用户隐藏的尽可能的URL)。
Any suggestions how i can get this working, other than displaying a button for the user to click on (i'd like to keep the url hidden from the user as much as possible).
推荐答案
有一个HTML黑客可用。
There is an HTML hack available.
<form action="http://url.goes.here" id="test" method="GET"></form>
<script type="text/javascript">
document.getElementById("test").submit();
</script>
如果您需要触发,从后面的code,可以做太多:
If you need to trigger that from a code behind, that can be done too:
Response.Write( @"<form action="http://url.goes.here" id="test" method="GET"></form>
<script type="text/javascript">
document.getElementById("test").submit();
</script> ");
由于INKEL可能会指出,这是引用站点[原文]规范的松散的跨pretation。它会做你想要什么,虽然
As Inkel might point out, that is a loose interpretation of the Referer[sic] spec. It will do what you want though.
这篇关于的Response.Redirect条头引荐 - 可以添加回来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!