Response.Redirect strips Header Referrer - Possible to Add it Back?(Response.Redirect 剥离 Header Referrer - 可以将其添加回来吗?)
问题描述
我正在使用 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 - 可以将其添加回来吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Response.Redirect 剥离 Header Referrer - 可以将其添加回来吗?


- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01