Search code examples
c#asp.nethttpclient

Redirect with header parameters


Is it possible to set parameters in the header of an HttpResponse, then redirect?

I tried something like this:

Response.Headers.Add("test", "1234"); 
Response.Redirect(www.targetpage.com);

and then

 var result = Request.Headers["test"];

My problem is that I don't find the parameter in my request result is always null and I cannot pass the the parameters in the url I need a solution with the header, thanks.


Solution

  • You are redirecting the client, so anything you sent to the client in the Response is probably flushed/discarded. If your intent is to control the redirect then you'd need to handle that in js on the client.

    There are many ways to implement your own messaging:

    How to send data from C# to JavaScript/AJAX webpage