Custom HTTP headers problem

Discussion in 'ASP .Net' started by Shelly, Nov 20, 2003.

  1. Shelly

    Shelly Guest

    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, Nov 20, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:055301c3afb4$57105c90$...
    > 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
    Mark Fitzpatrick, Nov 20, 2003
    #2
    1. Advertising

  3. Shelly

    Shelly Guest

    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 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" <> wrote in

    message
    >news:055301c3afb4$57105c90$...
    >> 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, Nov 20, 2003
    #3
  4. Shelly

    Guest Guest

    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 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" <> wrote in

    message
    >news:055301c3afb4$57105c90$...
    >> 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

    >
    >
    >.
    >
    Guest, Nov 20, 2003
    #4
  5. Shelly

    Rob Mayo Guest

    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" <> wrote in message
    news:055301c3afb4$57105c90$...
    > 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
    Rob Mayo, Nov 21, 2003
    #5
  6. "Shelly" <> wrote in message
    news:055301c3afb4$57105c90$...
    > 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
    John Saunders, Nov 22, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish

    custom HTTP headers

    Andy Fish, Nov 13, 2003, in forum: Java
    Replies:
    4
    Views:
    1,242
    Malcolm Hoar
    Nov 13, 2003
  2. dont bother
    Replies:
    0
    Views:
    769
    dont bother
    Mar 3, 2004
  3. Phil
    Replies:
    4
    Views:
    663
    Gabriel Genellina
    Jan 17, 2010
  4. Ian
    Replies:
    2
    Views:
    1,911
  5. Michal
    Replies:
    2
    Views:
    140
    Sam Roberts
    Nov 27, 2004
Loading...

Share This Page