コード例 #1
0
 /// <summary>
 /// Processes if request is modified.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="response">The response.</param>
 /// <param name="fileName">The name.</param>
 /// <param name="modifiedDate">The modifie date.</param>
 /// <returns></returns>
 static public bool ProcessModified(this HttpRequest request, HttpResponse response, string fileName, DateTime modifiedDate)
 {
     if (request.IsFileModified(fileName, modifiedDate))
     {
         response.AppendModifiedMeta(fileName, DateTime.Now);
         return(true);
     }
     else
     {
         response.ReturnNotModified(fileName, DateTime.Now);
         return(false);
     }
 }
        /// <summary>
        /// Transmits a static file with modified meta check.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <param name="fileName">Name of the file.</param>
        public static void TransmitStaticFile(this HttpResponse response, string fileName)
        {
            if (!System.IO.File.Exists(fileName))
            {
                response.StatusCode        = 404;
                response.StatusDescription = "Not found";
                return;
                //response.End();
            }
            DateTime modified   = System.IO.File.GetLastWriteTimeUtc(fileName);
            bool     isModified = System.Web.HttpContext.Current.Request.IsFileModified(fileName, modified);

            if (isModified)
            {
                response.AppendModifiedMeta(fileName, modified);
                response.TransmitFile(fileName);
            }
            else
            {
                response.ReturnNotModified(fileName, modified);
            }
        }