Not able view Custom Headers in ASP.NET

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.
 
K

Keith Patrick

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.
 
J

John Saunders

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top