Click here to Skip to main content
14,695,532 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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");


But in someothersite/test.aspx
request.headers["test"] is null.
Posted
Updated 14-May-12 22:43pm
v2

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
   
v2
Comments
Sandeep Mewara 15-May-12 5:10am
   
Correct! 5!
Manfred Rudolf Bihy 15-May-12 7:08am
   
Thanks!
koenigseggccxr 3-Oct-12 5:56am
   
I have a requirement similar to the original poster which I am really struggling with so any help would be really appreciated. I have to pass a token (string) in a HTTP request header to a 3rd party web application. In order to set up a test environment I create 2 ASP.Net websites, 1 which is my website which will set the HTTP request header value and the other which is simulating the 3rd party web application which will receive the HTTP request header. I have successfully set the request header on my website and verified this using the code below. I then perform a Response.Redirect to the simulated 3rd party web application which also uses the code below to determine if the token request header was received. Unfortunately the token request header is never displayed on the simulated 3rd party web application. I believe that I am setting the request header correctly so I feel that the problem is either with the way that I am attempting to transfer it to the simulated 3rd party web application or perhaps the request header is being sent to the simulated 3rd party web application but the way that I am checking for it is incorrect. I will be really grateful for any help or advice on this challenge. Here is the code I referred to earlier: headers = Request.Headers; for (int i = 0; i < headers.Count; i++) { string key = headers.GetKey(i); string value = headers.Get(i); Response.Write(key + " = " + value + " "); }
Mohd. Mukhtar 3-Oct-12 6:12am
   
you should create a WCF application and need to expose that service. In WCF you can coustmize header and data part separatly.
<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> ");
   
v2
Comments
SJBUPI 18-Jan-19 6:59am
   
Is the above code secure?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900