问题描述
我正在使用 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");
但是当我检查是否设置了 Referrer 标头时,接收页面测试为 false.
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 hack 可用.
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>
如果您需要从后面的代码中触发,也可以这样做:
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 可能指出的,这是对 Referer[sic] 规范的松散解释.它会做你想做的事.
As Inkel might point out, that is a loose interpretation of the Referer[sic] spec. It will do what you want though.
这篇关于Response.Redirect 剥离 Header Referrer - 可以将其添加回来吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)