3

I have an IHttpHandler serving dynamically generated files. I wish to respond to HEAD requests to let the client know whether the file has changed.

I need to send the last change date and the file size, do I have to use Response.AddHeader() or is there a cleaner way?

Mart
  • 5,608
  • 3
  • 32
  • 45
  • So this is not a file that you're happy for IIS to serve? Custom logic in other words? – Nik May 19 '11 at 11:36
  • I actually wish to generate the file on first request as it is time consuming, not at every internal change. The first HEAD or GET (re)generates the file if needed. – Mart May 19 '11 at 12:19
  • I don't think there's a cleaner way, or more accurately, I don't think setting the header like that is very dirty :) – Nik May 25 '11 at 20:45

1 Answers1

0

For the last modified time, you can call:

Response.Cache.SetLastModified()

Are you sure you need to set the size? The Framework usually takes care of that automatically, based on the actual size of the response.

RickNZ
  • 18,448
  • 3
  • 51
  • 66