469,631 Members | 970 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Custom HTTP headers problem

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
Nov 18 '05 #1
5 6661
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

"Shelly" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
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

Nov 18 '05 #2
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
-----Original Message-----
Shelly,
I was just thinking about how this would behave, and one of mythoughts is, the AppendHeader will place the new header at the end of thequeue. In all likelyhood this would actually occur after the 302 redirect issent. I'm not sure that in the case of a redirect that it will actually everbe picked up by the browser since after the redirect is received everythinggets thrown away. Unless you're emitting the headers from a global functionfor all pages, I'm not sure that they'll transfer like this.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrotnPage

"Shelly" <an*******@discussions.microsoft.com> wrote in messagenews:05****************************@phx.gbl...
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

.

Nov 18 '05 #3
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
-----Original Message-----
Shelly,
I was just thinking about how this would behave, and one of mythoughts is, the AppendHeader will place the new header at the end of thequeue. In all likelyhood this would actually occur after the 302 redirect issent. I'm not sure that in the case of a redirect that it will actually everbe picked up by the browser since after the redirect is received everythinggets thrown away. Unless you're emitting the headers from a global functionfor all pages, I'm not sure that they'll transfer like this.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrotnPage

"Shelly" <an*******@discussions.microsoft.com> wrote in messagenews:05****************************@phx.gbl...
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

.

Nov 18 '05 #4
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" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
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

Nov 18 '05 #5
"Shelly" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
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?
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Google Mike | last post: by
3 posts views Thread by Jared | last post: by
3 posts views Thread by Jacky | last post: by
reply views Thread by Dean Hallman | last post: by
3 posts views Thread by Alexander Smirnov | last post: by
reply views Thread by msnews.microsoft.com | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.