Custom HTTP headers problem

  • Thread starter Thread starter Shelly
  • Start date Start date
S

Shelly

hi,

I am trying to create a custom HTTP header and trying to
access that variable on another ASP.NET webpage.

Following is the code base-
I use the following code to set the header
Response.AppendHeader("MYKEY", "myValue")

and do a redirect to SecondPage.aspx

Response.Redirect("SecondPage.aspx")

In the second page, I try to retrieve the value using the
following code

Response.Write(Request.Headers.Get("MYKEY"))

I dont see any reponse back. Am I setting the header in a
inapproriate way? What is the reason y i am not able to
see my custom http header on the destination page. I am
able to get the standard http headers like "Host","User-
Agent" etc....

Can anyone enlighten me???

Thanks .. :)
Shelly
 
Shelly,
I was just thinking about how this would behave, and one of my
thoughts is, the AppendHeader will place the new header at the end of the
queue. In all likelyhood this would actually occur after the 302 redirect is
sent. I'm not sure that in the case of a redirect that it will actually ever
be picked up by the browser since after the redirect is received everything
gets thrown away. Unless you're emitting the headers from a global function
for all pages, I'm not sure that they'll transfer like this.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrotnPage
 
Thanks very much Mark,

really appreciate your help. As per your explanation, when
I do a response.redirect, I would loose all the header
information which I set, am i right?

the scenario is like this. i have an application which
send me some information in the HTTP header. As a testing
effort, before intergrating to the application, I wanted
to simulate the scenario where I could trap and header
info thro the request object. But how do i set the custom
HTTP header and pass it to my destination page, without a
response.redirect ?? can you suggest the ways for testing
the custom http header retrieval??

Thanks a bunch... :)
Shelly
 
Thanks very much Mark,

really appreciate your help. As per your explanation, when
I do a response.redirect, I would loose all the header
information which I set, am i right?

the scenario is like this. i have an application which
send me some information in the HTTP header. As a testing
effort, before intergrating to the application, I wanted
to simulate the scenario where I could trap and header
info thro the request object. But how do i set the custom
HTTP header and pass it to my destination page, without a
response.redirect ?? can you suggest the ways for testing
the custom http header retrieval??

Thanks a bunch... :)
Shelly
 
I believe I read in old ASP, that custom headers, thought they may be sent,
were not parsed into the Request object.
I would imagine the same rule applies to ASP.NET
 
Shelly said:
hi,

I am trying to create a custom HTTP header and trying to
access that variable on another ASP.NET webpage.

Following is the code base-
I use the following code to set the header
Response.AppendHeader("MYKEY", "myValue")

and do a redirect to SecondPage.aspx

Response.Redirect("SecondPage.aspx")

In the second page, I try to retrieve the value using the
following code

Response.Write(Request.Headers.Get("MYKEY"))

AppendHeader would add the header to the response. The response is the 302
message redirecting to SecondPage.aspx. I'm sure the user's browser receives
the 302 page along with your custom header, but why would it send the header
back when it requests SecondPage.aspx?
 
Back
Top