I am using http meta refresh to reflesh current page to keep session live. I am using VSTS 2008 + C# + .Net 3.5 and developing ASP.Net application.
My question is, is it possible to send from client (browser) side If-Not-Modified-Since request header to server side and check if at server side responses 304 Not-Modified header to client? (I want to use this to optmize bandwidth and overhead at server.)
If yes, could anyone recommend me some sample code at client side and at server side how to implement this?
You shouldn't use META Refresh. If you want to reload the page, use the JavaScript method window.location.reload(false);
I explain why here: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/meta-refresh-causes-additional-http-requests.aspx and http://blogs.msdn.com/b/ieinternals/archive/2010/07/08/technical-information-about-conditional-http-requests-and-the-refresh-button.aspx
You can use jQuery's Ajax api see the documentation here, there is a
ifModified
param. Moreover, the use of HTTP Meta Refresh is discouraged by W3CI'm not super familiar with ASP.NET, but in general, for something like this, consider using ETags.
This could potentially be addressed with the
HtmlMeta
class that was added in .NET 2.0. It allows programmatic access to the meta keywords. You can check it out here.