带有http标头的Response.redirect [英] Response.redirect with http headers

查看:67
本文介绍了带有http标头的Response.redirect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了httpheader并重定向到其他Web应用程序,如果我检查request.header它是null,则远程Web应用程序中的




请建议一种方法将标题发送到其他网络应用程序。



我试过的示例代码。



I have added httpheader and redirected to other web application,
in remote web application if i check request.header it was null.

please suggest a way to send header to other web application.

sample code which i have tried.

response.headers.add("test", "1234");
response.redirect("http://someothersite/test.aspx");





但在someothersite / test.aspx

request.headers [test]为空。



But in someothersite/test.aspx
request.headers["test"] is null.

推荐答案

啊,这里似乎有某种深刻的误解。响应标头从服务器发送到客户端,该客户端通常是IE,FF,Chrome等浏览器。如果接收方能够正确解释它,则标头才有意义。当您发送 Response.Redirect 并设置一些类似于测试的标头时,浏览器不会将此标头转发到它现在重定向到的网站。如果您绝对倾向于将一些参数传递给浏览器将重定向到的站点,则必须将该参数作为URL参数传递。



类似于Request头是浏览器用于将有关当前请求的信息传递给服务器的一些信息。此信息将在服务器上用于正确解释请求。



如果您有任何疑问,请给我留言,我会尝试进一步解释。



问候,



Manfred
Ahmmm, there seems to be some kind of deep misunderstanding going on here. Response headers are sent from the server to the client and that client is usually a browser like IE, FF, Chrome etc.. Headers only make sense if the receiving party can interpret it correctly. When you are sending a Response.Redirect and also set some header like test, the browser will not forward this header to the site it is now redirecting to. If you are absolutely bent on passing some parameter to the site the browser will redirect to, you will have to pass that parameter as an URL parameter.

Similarily a Request header is some information the browser uses to pass back information about the current request to the server. This information will be used on the server to interpret the request correctly.

If you have any doubts, leave me a comment and I'll try to explain further.

Regards,

Manfred


<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> ");


这篇关于带有http标头的Response.redirect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆