Tech Off Thread

3 posts

HTTP Header / ASP .NET problem - need help.

Back to Forum: Tech Off
  • User profile image


    I want to develop a HttpModule which adds a CUSTOM HTTP Header "Response.AddHeader("X-MyHeader", "testvalue")". But why I cannot get the header in the next request ?! I´ve tested this way: request.Headers[..] and request.Servervariables["ALL_RAW"]. But I doesn´t get my own defined HTTP Header back from the client. Is it possible - or what I´m doing wrong ?

  • User profile image

    Thats not how HTTP works.

    When you set the header, it is sent back to the client with the rest of the HTTP headers (eg HTTP status code, caching info, cookies etc).

    When the client sends the next request, it will NOT include your header. The headers are purely response headers and are only used by the browser to decide how to handle the page. They are forgotten as soon as the page has been loaded.

    If you wish to save information on the client between requests, use a cookie.

  • User profile image

    or in the url like the cookieless session. Smiley or perhaps in the viewstate ?!

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.