I’m wondering how to send custom headers using a redirect, currently with no success. I’m attempting to do the following:
Response.Clear();
Response.AddHeader("X-PagePathNode", "/public/IPOs.aspx");
Response.Status = "301 Moved Permanently";
Response.StatusCode = 301;
Response.AppendHeader("Location", "default.aspx");
Response.End();
When I’m looking at the Request object’s headers, the new header isn’t there. Looking at firebug, the following is happening. The page which is doing the location change has the new header. However the page the location has redirected too doesn’t contain the new header in the Request.
My Question is how to redirect to a new location with the new headers from redirect into the Request object of the new Location.
Essentially I want to be able to: Request.Header[“X-PagePathNode"] on the page load to view the headers added from the redirect.
Appreciate any help.
There’s a couple of different approaches you can try. Among your tools are Session variables, cookies, the Referrer HTTP header, and a query string.
From what I understand, you want to issue a HTTP 301 redirect from page
Ato pageB, and from pageB, you wish to acknowledge the fact that this redirect has taken place (and maybe add some additional headers or logic).Here’s a few approaches:
A, set aSessionvariable, and check for its existance in pageB(then you probably want to remove saidSessionvariable).A, set a cookie, and check for its existence in pageB.B, checkRequest.UrlReferrerand see if it’s pageA, then do your logic.