當我使用下面的代碼下載一個ZIP文件它似乎工作。但是,當我嘗試打開下載的ZIP文件時,出現'無效的壓縮文件夾'消息。當我在記事本中打開ZIP文件時,我發現它充滿了HTML。ZIP下載包含html內容
string fp = Server.MapPath("directory\\file.zip");
FileInfo file = new FileInfo(fp);
if (file.Exists)
{
Response.ClearContent();
Response.AddHeader("content-disposition","attachment; filename=" + file.Name);
Response.AddHeader("content-length", file.Length.ToString());
Response.ContentType = "application/zip";
Response.TransmitFile(file.FullName);
Response.End();
}
的問題,我似乎無法修復可能與是當我嘗試在文件(http://website.com/downloads/file.zip
),我得到一個重定向(http://website.com/login.aspx
)作爲登錄,即使地址手動鍵入管理員。任何指望在哪裏看,將不勝感激。
HTML代表什麼?登錄表單?錯誤頁面?或... –
它創建一個通用的錯誤頁面。 – Jesse
和什麼是錯誤信息? –