您好,我需要從ASHX提供一個GZ壓縮文件。在代碼中,我已經有了明確的字符串:生成並提供在ASP.NET中壓縮的gz
public void ProcessRequest(HttpContext context)
{
// this is the code without compression
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
Response.ContentEncoding = Encoding.UTF8;
Response.ContentType = "text/xml";
// this is the string to compress and send to the client
string xml = GenerateXml();
Response.Write(output);
Response.End();
}
現在,我需要在GZ
- 壓縮XML(用於壓縮sitemap文件http://www.sitemaps.org/protocol.php#sitemapXMLExample)
- 將其發送到響應。的OutputStream
- 設置一些HTTP響應報頭(內容類型,編碼,ECC)
任何幫助?
我們不是按需生成的文件,而是一個時間表。由於我們的站點地圖包含近一百萬個URL,因此這些數據會變得非常多。我們在生成文件時壓縮內容,然後將文件存儲在cdn中,以便在請求時由前端提供服務。 – 2010-05-13 15:51:03