Not able view Custom Headers in ASP.NET

  • Thread starter Thread starter Jacky
  • Start date Start date
J

Jacky

hi,

I am trying to view the custom headers in an ASP.NET page.
I am able to view all the standard headers using the
method Request.Headers.Get(). But if i set a custom header
using Response.AddHeader("ID","value"), the key or value
doesnt appear in the Request.Headers collection. What
could be reason to this problem?

Does ASP.NET support setting and viewing custom http
headers. If yes, how do i simulate creating and viewing it
in my code.

Thanks in advance.
 
It won't appear in the request until the response has actually occured,
meaning you need to append the header, let the page finish whatever it was
doing, and then grab the header on the next postback. BTW: It looks like if
you do a Response.Redirect that the appended headers get discarded.
 
Jacky said:
hi,

I am trying to view the custom headers in an ASP.NET page.
I am able to view all the standard headers using the
method Request.Headers.Get(). But if i set a custom header
using Response.AddHeader("ID","value"), the key or value
doesnt appear in the Request.Headers collection. What
could be reason to this problem?

Why would Response.AddHeader affect Request.Headers? Response.AddHeader adds
a header to the outgoing response. Request.Headers is the headers which were
sent with the request. These two have nothing to do with each other.

Perhaps you're confusing headers with cookies?
 
Back
Top