public override void ExecuteResult(ControllerContext context) { var httpContext = context.HttpContext; var request = httpContext.Request; var response = httpContext.Response; // Fix Last Modified Time. We might need it soon // if we encounter a Range: and If-Range header // Using UTC time to avoid daylight savings time bug 83230 var lastModified = new DateTime(LastModifiedUtc.Year, LastModifiedUtc.Month, LastModifiedUtc.Day, LastModifiedUtc.Hour, LastModifiedUtc.Minute, LastModifiedUtc.Second, 0, DateTimeKind.Utc); // Because we can't set a "Last-Modified" header to any time // in the future, check the last modified time and set it to // DateTime.Now if it's in the future. // This is to fix VSWhidbey #402323 var utcNow = DateTime.UtcNow; if (lastModified > utcNow) { // use 1 second resolution lastModified = new DateTime(utcNow.Ticks - (utcNow.Ticks % TimeSpan.TicksPerSecond), DateTimeKind.Utc); } LastModifiedUtc = lastModified; // Generate ETag if empty if (ETag.IsEmpty()) { ETag = GenerateETag(httpContext, lastModified, utcNow); } // Determine applicable file responder var responder = ResolveResponder(request); // Execute response (send file) if (responder.TrySendHeaders(httpContext)) { responder.SendFile(httpContext); } // Finish: invoke the optional callback OnExecuted?.Invoke(); }