Response.Clear(); Response.ContentType = "text/CSV"; Response.CacheControl = "no-cache"; Response.AddHeader("Pragma", "no-cache"); Response.Expires = -1; Response.AddHeader("Pragma", "must-revalidate"); Response.AddHeader("Cache-Control", "must-revalidate"); Response.AddHeader("Accept-Header", csvResults.Length.ToString()); Response.AddHeader("Content-Length", csvResults.Length.ToString()); Response.AddHeader("content-disposition", "attachment; filename=test.csv"); Response.Write(csvResults.ToString()); Response.Flush(); Response.End(); protected void Application_BeginRequest(Object sender, EventArgs e) { string requestURL = Request.Url.ToString().ToLower(); if (requestURL.StartsWith("http://")) { Response.Redirect(requestURL.Replace("http:", "https:")); } } HTTP/1.1 200 OK Date: Tue, 09 Nov 2010 14:23:50 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 4.0.30319 Pragma: no-cache Pragma: must-revalidate content-disposition: attachment; filename="test.csv" Cache-Control: no-cache Pragma: no-cache Expires: -1 Content-Length: Content-Type: text/CSV "COL1","COL2","COL3" "VAL1","VAL2","VAL3" "VAL1","VAL2","VAL3" "VAL1","VAL2","VAL3" Response.ClearHeaders(); Response.AddHeader("Cache-Control", "no-store, no-cache");