0

I am adding multiple custom headers in my HttpResponse and on the next request from the browser for the page, I want to read those custom headers and determine if I need to send a 304 response to the browser.

I added the custom headers using Response.AddHeader but on the next request from the browser, the custom headers were not sent.

The browser did recieve the custom headers in the response stream but did not send them on the subsequent request.

I'm expecting the headers since I need to read them on the first request and not on post requests.

NOTE: I don't want to use cookies since I don't want to increase payload. I don't want to use sessions since I don't want to burden the server. My aim to decrease processing in the server as much as possible. As I've mentioned in my comment, I read about ETags and I'm hoping the technique that's used in ETags could be used for custom headers.

Chris Serrao
  • 135
  • 2
  • 12
  • 2
    Browsers don't do that. Headers are not cookies. – SLaks Feb 24 '14 at 17:00
  • If you add a custom response header the browser will not include them in the next request – Alex K. Feb 24 '14 at 17:01
  • You can receive a custom header from the browser if client-side (i.e. Javascript) code adds this when performing a request. The browser won't do this on its own. – elolos Feb 24 '14 at 17:02
  • Why don't you set the data in the view page as hidden fields or things like this and receive it inside some HTTP Module and then do the validation for the data and act accordingly. This will be easy than adding in the headers. Also, let us know if you are using MVC or asp.net alone. – Saravanan Feb 24 '14 at 17:06
  • I've heard of ETags and I was hoping that custom headers would work the same. The intent is to get the information when the user types in the url into the browser, not invoked via javascript or a postback. I don't want to make the request too heavy and adding values to cookies will increase payload for requests. – Chris Serrao Feb 24 '14 at 17:12

1 Answers1

1

There are other ways of of passing information between requests. See this discussion.

You can also use session variables.

Community
  • 1
  • 1
RossG
  • 434
  • 3
  • 8