Last post Mar 24, 2010 12:25 PM by kahlua001us
Mar 24, 2010 01:56 AM|kahlua001us|LINK
I have this code that does not return a 304 not modified, instead always a 200 ok found. Any clues what I'm doing wrong?
string AdminContentPath = context.Server.MapPath(FullPath.Replace("/ADMIN/ASSETS/", "/Content/"));
context.Context.Response.ContentType = GetContentType(AdminContentPath);
Mar 24, 2010 06:35 AM|icecape67|LINK
context.Response.StatusCode = 304;
Mar 24, 2010 09:06 AM|g_rahman|LINK
I'm pretty sure ASP.NET isn't going to check for modifications automatically. You'll probably need to check for the If-Modified-Since request header and compare it to the current file dependencies to see if it has been modified. If not, do as was mentioned
above and set the status code to 304.
Same thing with ETags probably. You'll have to generate the ETag before you pass the file down the pipeline and check to see if the request headers contain the same ETag.
Mar 24, 2010 11:15 AM|kahlua001us|LINK
Is there code on how to do this? Also I've tried to set the status code to 304 but the browser will then not completely download everything on a page and some files that the module pushes thru to the browser are empty. I think what I'm doing is not sending
the right headers to the browser.
Mar 24, 2010 11:38 AM|kahlua001us|LINK
Also I read somewhere that if the cacheability is set to public then IIS7 automatically sets the control headers. Not sure if this is true.
Mar 24, 2010 12:25 PM|kahlua001us|LINK
Got it. Found a great article http://aspnetresources.com/blog/setting_last_modified_header_2.aspx.aspx
Thanks for all your help.