setting If-Modified-Since programmatically

S

Sam Carleton

I would like to set the If-Modified-Since to the last modified time of
the file, how does one go about doing that?
 
K

Karl Seguin [MVP]

If it's an ASP.NET page, you might be able to play with Response.AddHeader -
though I'm not sure if IIS will overwrite the value. If IIS does overwrite
the value OR you want to control the last-modified for an non-aspx.net file,
you're likely stuck with having to write an ISAPI filter. With IIS 7, you'll
be able to write those in .NET (yay).

Karl
 
S

Sam Carleton

Karl said:
If it's an ASP.NET page, you might be able to play with Response.AddHeader -
though I'm not sure if IIS will overwrite the value. If IIS does overwrite
the value OR you want to control the last-modified for an non-aspx.net file,
you're likely stuck with having to write an ISAPI filter. With IIS 7, you'll
be able to write those in .NET (yay).

Karl,

Thank you! I have been a windows developer for many moons now. I have
tabled in web programming, but.. Well, it is a very different world;)
Question: now do I confirm the code is working? Here is what I have
and I am not seeing anything different in the generated HTML:

FileInfo fi = new FileInfo(this.Request.PhysicalPath);
this.Response.AddHeader("If-Modified-Since",
fi.LastWriteTimeUtc.ToString("r"));

Sam
 
K

Karl Seguin [MVP]

headers aren't rendered in the html.

Get a tool like fiddler (www.fiddlertool.com, free) set it up to proxy your
browser (IE should automatically detect it running) and hit the page. Then
look at the response headers before and after, hopefully something changed.

Karl
 
S

Sam Carleton

Karl said:
headers aren't rendered in the html.

Get a tool like fiddler (www.fiddlertool.com, free) set it up to proxy your
browser (IE should automatically detect it running) and hit the page. Then
look at the response headers before and after, hopefully something changed.

Karl,

Thanks a million! Fiddler shows that it is working!!!!! I much
appreciate it!

Sam
 

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,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top