locked
is it possible to modify request headers are redirect response to a different page RRS feed

  • Question

  • User1732652436 posted

    Hi,

    is it possible to modify request headers are redirect response to a different page.


    Thanks


    Monday, November 23, 2009 8:00 AM

All replies

  • User2130758966 posted

    Hey,

    Could you explain your situation? Do you want to redirect users to a different page? You can use Response.Redirect like:

    Response.Redirect("~/otherPage.aspx");


    Monday, November 23, 2009 8:13 AM
  • User1732652436 posted

    A Response.Redirect will simply redirect the request to a different page. But what want to achieve is to add custom http headers so that the other page is able to access them.


    Response.Headers.Add didnt do it for me.

    Monday, November 23, 2009 10:48 AM
  • User2130758966 posted

    I think if you use the built in response.redirect after adding headers then all headers are wiped before issuing the 302 redirect.


    If you handle it all yourself it might work. In this post Vikram shows how to create a custom redirect extension method:

    I would try using his 3.5 extension method and adding in the extra headers before the location header.

    Monday, November 23, 2009 10:52 AM
  • User1732652436 posted

    It seems though the headers are not preserved during a reponse redirect.


                string appURL = ConfigurationManager.AppSettings["APPURL"];
                Response.AppendHeader("Username", "user123");
                Response.AppendHeader("Password", "password");
                Response.Status = "301 Moved permanently";
                Response.AppendHeader("Location", appURL);
                Response.End();



    Is there a way to persist headers between requests without using handlers. What can be done is examine cookies in request and add add headers correspondingly examining the values in the cookies in each request, but is there another approach to this.


    thanks in advance

    Tuesday, November 24, 2009 1:04 AM